【发布时间】:2016-08-02 06:26:40
【问题描述】:
我通过这种方式为 UITextField 添加了底部边框:
let bottomLine = CALayer()
bottomLine.frame = CGRectMake(0.0, self.frame.height, self.frame.width, CGFloat(borderWidth))
bottomLine.backgroundColor = borderColor.CGColor
self.borderStyle = UITextBorderStyle.None
self.layer.addSublayer(bottomLine)
我得到了这个:
我想下移边框。为此,我以这种方式设置边框:
bottomLine.frame = CGRectMake(0.0, self.frame.height + 5, self.frame.width, CGFloat(borderWidth))
在这里,我将其增加 5px。但它超出了文本字段的框架。但我无法调整UITextField 的高度:
如果我以编程方式设置它,应用程序会在刷新可设计对象时挂起(我使用的是UITextField 的IBDesignable 子类)。
【问题讨论】:
-
看到这个对你有帮助的时候stackoverflow.com/questions/38303520/…
标签: ios swift uiview uitextfield