iOS:向下移动UITextField的下边框

时间:2016-08-02 06:26:41

标签: ios swift uiview uitextfield

我以这种方式向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)

我得到了这个:

enter image description here

我想向下移动边框。为此,我以这种方式设置边框:

bottomLine.frame = CGRectMake(0.0, self.frame.height + 5, self.frame.width, CGFloat(borderWidth))

我在这里增加5px。但它超越了文本字段的框架。但我无法调整UITextField的身高:

enter image description here

如果我以编程方式设置它,应用程序会挂起刷新的可设计项(我正在使用IBDesignable的{​​{1}}子类。

1 个答案:

答案 0 :(得分:1)

选择show attribute inspector然后更改边框样式

见下图enter image description here

相关问题