ios - 从文本字段中删除圆角,保持背景不透明度 iOS Swift

标签 ios uitextfield uikit opacity

在 Xcode 6.3 中,在创建 TextView 时,为边框样式提供了 4 个选项。

enter image description here

圆角边框样式提供了更改背景(不是文本)不透明度的选项。

方角边框样式的 alpha 值只改变文本的不透明度,而不改变文本字段的背景。

如何让方角文本字段的背景不透明度为 0.5 Alpha 值,但文本不透明度为 0.0 Alpha 值?

最佳答案

您可以通过编程方式设置您想要的任何组合。例如:

override func viewDidLoad() {
    super.viewDidLoad()

    let backColor = UIColor(red: 0, green: 0, blue: 0, alpha: 0.5)
    myTextField.backgroundColor = backColor

    let textColor = UIColor(red: 0, green: 0, blue: 0, alpha: 0.5)
    myTextField.textColor = textColor

}

您还可以在属性检查器中将背景或文本颜色设置为 Clear Color

关于ios - 从文本字段中删除圆角,保持背景不透明度 iOS Swift,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31024524/

相关文章:

ios - 核心数据对象的顺序改变,核心数据合并后上下文之间不同

ios - 滚动后 UITableViewCell 标签发生变化

ios - 在 UITextView 中禁用光标和复制/粘贴(快速)

ios - didBarButton.enabled 带有 && 语句

iphone - UIImagePickerController.frame 未全屏

ios - 在 Mapview Xcode 中更新位置

ios - 按比例调整 UIImage 的大小然后裁剪

ios - 我可以使用带有返回按钮的 phonePad 键盘吗?

ios - UINavigationBar 外观和 Facebook-Sheet Bug

iphone - UIViewController 中 subview 的布局和大小