ios - Adding multiple sublayers to UIView will only display one -
trying add bottom border login system, have used following code:
var bottomborder = calayer() bottomborder.frame = cgrectmake(0.0, useremailaddresstextfield.frame.size.height - 1, useremailaddresstextfield.frame.size.width, 1.0) bottomborder.backgroundcolor = uicolor.blackcolor().cgcolor useremailaddresstextfield.layer.addsublayer(bottomborder)
i trying password textfield well. have used various amount of techniques none seem work.
first attempt: adding same code again, shows bottom border second bar.
second attempt: tried same thing different variable being bottombordertwo , replicating code, wouldn't work either. solutions?
create common function
func addbottomlayertotheview(view:uiview) { var bottomborder = calayer() bottomborder.frame = cgrectmake(0.0, view.frame.size.height - 1, view.frame.size.width, 1.0) bottomborder.backgroundcolor = uicolor.blackcolor().cgcolor view.layer.addsublayer(bottomborder) }
call function after creating textfields or other views need bottom layer like:
in viewdidload()
addbottomlayertotheview(textfield)
addbottomlayertotheview(textfield2)
addbottomlayertotheview(anyview)
Comments
Post a Comment