【问题标题】:iOS: Moving bottom border of UITextField downiOS:向下移动 UITextField 的底部边框
【发布时间】: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 的高度:

如果我以编程方式设置它,应用程序会在刷新可设计对象时挂起(我使用的是UITextFieldIBDesignable 子类)。

【问题讨论】:

标签: ios swift uiview uitextfield


【解决方案1】:

选择显示属性检查器然后更改边框样式

见下图

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-10-24
    • 1970-01-01
    • 1970-01-01
    • 2021-05-14
    相关资源
    最近更新 更多