ios - 如何只保留 UITextField 的下边框?

标签 ios swift uitextfield

有必要在 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/

相关文章:

iphone - iOS 5 创建自定义 View

ios - 解析 : send push notification from own server

ios - Alamofire: 'weak' 无法应用于非类类型错误

ios - 点击下一步/完成时在不同 UITableViewCell 中的 UITextField 中导航

javascript - navigator.clipboard.writeText() 不适用于特定的 IOS 设备

ios - swift 2.2 : creating random playlist for AVAudioPlayer

ios - 这个数组扩展中的 "+"闭包在做什么?

ios - 修改UINavigationBar标题字体和文字颜色的方法

iphone - iOS应用程序中的日期选择器

ios - 如何重命名文本字段占位符