Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/swift/17.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios 使用swift更改自定义属性检查器值_Ios_Swift_Xcode_Uitextfield - Fatal编程技术网

Ios 使用swift更改自定义属性检查器值

Ios 使用swift更改自定义属性检查器值,ios,swift,xcode,uitextfield,Ios,Swift,Xcode,Uitextfield,我已为我的文本字段创建了自定义属性检查器: @IBInspectable var bottomColor: UIColor = UIColor.clear { didSet { if bottomColor == UIColor.clear { self.borderStyle = .roundedRect } else { self.borderStyle = .bezel }

我已为我的文本字段创建了自定义属性检查器:

@IBInspectable var bottomColor: UIColor = UIColor.clear {
    didSet {
        if bottomColor == UIColor.clear {
            self.borderStyle = .roundedRect
        } else {
            self.borderStyle = .bezel
        }
        self.setNeedsDisplay()
    }
}

现在我想在提交带有空文本字段的表单时,将
bottomColor
设置为
red
。哪种方法最好?

我把我的逻辑放在这里

为此,您需要添加UITextField的底部边框

然后,您需要设置所需底部边框的颜色


删除相同内容后,您需要设置
0
UITextField的底部边框宽度
clear color of border.

谢谢。成功了