有必要在 UITextField 处只保留底部边框。出于某种原因,我的代码不起作用。
let bottomLine = CALayer()
bottomLine.frame = CGRect(x:0.0, y:1.0, width: myTextField.frame.width,
height: myTextField.frame.height - 1)
bottomLine.backgroundColor = UIColor.white.cgColor
myTextField.borderStyle = UITextBorderStyle.None
myTextField.layer.addSublayer(bottomLine)
最佳答案
替换这个
bottomLine.frame = CGRect(x:0.0, y:1.0, width: myTextField.frame.width,height: myTextField.frame.height - 1)
与
bottomLine.frame = CGRect(x:0.0, y:myTextField.frame.height - 1, width: myTextField.frame.width,height: 1)
关于ios - 如何只保留 UITextField 的下边框?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50759483/