【发布时间】:2016-10-17 22:57:23
【问题描述】:
仅当我不使用任何约束时,我的显示底部边框的代码才有效。一旦我这样做,底线就消失了。有什么原因或解决方案可以解决这个问题吗?这是我当前的代码。我已经看到了很多解决方案的答案,但是当我添加约束时没有一个有效。
func useUnderline() {
var bottomLine = CALayer()
bottomLine.frame = CGRect(x: 0.0, y: self.frame.height - 1, width: self.frame.width, height: 1)
bottomLine.backgroundColor = UIColor.white.cgColor
self.borderStyle = UITextBorderStyle.none
self.layer.addSublayer(bottomLine)
}
【问题讨论】:
标签: ios swift uitextfield constraints ios-autolayout