Add bottom line to view in SwiftUI / Swift / Objective-C / Xamarin

前端 未结 22 2310
自闭症患者
自闭症患者 2020-11-27 09:19

I would like to keep the border at the bottom part only in UITextField. But I don\'t know how we can keep it on the bottom side.

Can you please advise m

22条回答
  •  清酒与你
    2020-11-27 09:45

    let border = CALayer()
         let lineWidth = CGFloat(0.3)
         border.borderColor = UIColor.lightGray.cgColor
         border.frame = CGRect(x: 0, y: emailTextField.frame.size.height - lineWidth, width:  emailTextField.frame.size.width, height: emailTextField.frame.size.height)
         border.borderWidth = lineWidth
         emailTextField.layer.addSublayer(border)
         emailTextField.layer.masksToBounds = true
    

    Tutorial

提交回复
热议问题