2017-10-04 57 views
0

當我設置角輻射屬性時,UITextfield的邊緣從所有角落剪取。 有沒有人知道爲什麼會發生這種情況? 謝謝!!!爲什麼textfield的邊緣被剪切?

我的代碼:

override func viewDidLoad() { 
      super.viewDidLoad() 
    fullNameTextField.layer.cornerRadius = fullNameTextField.frame.size.height/2 
    } 

結果: enter image description here

我想實現這一點:enter image description here

+0

嘗試添加'fullNameTextField.layer.masksToBounds = TRUE' – Tj3n

+0

嘗試,但不工作:(@ Tj3n –

+0

給一個'borderwidth'和'bordercolor'然後設置'cornerRadius '和'clipsToBounds',然後看看問題是否解決。@UdayBabariya – iPeter

回答

1

試試你的邊框樣式設置爲none修復和使用層繪製你的邊界:

fullNameTextField.borderStyle = .none 
    fullNameTextField.layer.borderColor = UIColor.gray.cgColor 
    fullNameTextField.layer.borderWidth = 1.0 
    fullNameTextField.layer.cornerRadius = fullNameTextField.frame.size.height/2 
0

是哥們了,因爲你的文本字段包含畦風格。在Interface Builder中選擇文本字段,然後選擇圓角畦的風格,如果你需要的邊界..將一個圖像看看,你可以從故事板:)

here is the image

相關問題