swift - 如何删除文本框边框

标签 swift uitextfield

我想删除 UITextField 的边框,但保留圆形形状以获得这种结果:

enter image description here

我已经在界面生成器中更改了文本字段背景颜色。

如果我选择“无边框”选项,文本字段将不再圆角。

最佳答案

从界面生成器中将其更改为无边框。 然后在viewcontroller中写入:

textfield.backgroundColor = UIColor.lightGrey
textfield.layer.cornerRadius = 5

关于swift - 如何删除文本框边框,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53889140/

相关文章:

ios - 从左到右标记在 Swift 中不起作用

iphone - 在 UITableViewCells 中维护 UITextFields 中的文本

ios - 将多个 UITextFiled 附加到同一个 IBAction 不会保留触发事件

ios - 更新 textFieldDidBeginEditing 方法中的约束会导致文本弹回

iphone - 在编辑时禁用 UITextField 上的键盘

ios - 将 TextField 存储到自定义类中

ios - tableView.insertRows 抛出 NSException,但不是当 `insertRows` at `[[0,0]]`

arrays - 将恰好 2 个相等的元素添加到数组中

swift - 将 nil 日期排序到数组的末尾

字符串长度 Swift