代码之家  ›  专栏  ›  技术社区  ›  Uday Babariya

为什么文本字段的边缘会被剪裁?

  •  0
  • Uday Babariya  · 技术社区  · 8 年前

    有人知道为什么会这样吗?

    我的代码:

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

    结果: enter image description here

    enter image description here

    2 回复  |  直到 8 年前
        1
  •  1
  •   Au Ris    8 年前

    尝试将边框样式设置为“无”,并在图层中使用以下命令绘制边框:

        fullNameTextField.borderStyle = .none
        fullNameTextField.layer.borderColor = UIColor.gray.cgColor
        fullNameTextField.layer.borderWidth = 1.0
        fullNameTextField.layer.cornerRadius = fullNameTextField.frame.size.height / 2
    
        2
  •  0
  •   Vinodh    8 年前

    是的,因为您的文本字段包含boder样式。在界面生成器中,选择文本字段,如果需要边框,请选择圆角boder样式。。附加一个图像看看,你可以从情节提要中修复它:)

    here is the image