为什么textfield的边缘被剪切?

问题描述:

当我设置角辐射属性时,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

试试你的边框样式设置为none修复和使用层绘制你的边界:

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

是哥们了,因为你的文本字段包含畦风格。在Interface Builder中选择文本字段,然后选择圆角畦的风格,如果你需要的边界..将一个图像看看,你可以从故事板:)

here is the image