2016-08-02 72 views
0

我加底邊框的UITextField這樣:的iOS:移動的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

如果我以編程方式設置它,應用程序掛在清爽designables(我用IBDesignable子類的UITextField)。

+0

看到這一次它可以幫助你http://stackoverflow.com/questions/38303520/ios-uitextfield-border-style-in -swift/38303809#38303809 –

回答

1

選擇顯示屬性檢查器,然後更改邊框樣式

見下圖enter image description here