Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/swift/16.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 如何获取UISearchBar的颜色?_Ios_Swift_Uisearchbar - Fatal编程技术网

Ios 如何获取UISearchBar的颜色?

Ios 如何获取UISearchBar的颜色?,ios,swift,uisearchbar,Ios,Swift,Uisearchbar,正如我们所知,我们通过这行代码更改搜索栏的文本颜色,效果良好: UITextField.appearance(whenContainedInInstancesOf: [UISearchBar.self]).defaultTextAttributes = [NSAttributedStringKey.foregroundColor.rawValue: UIColor.blue] 颜色的占位符是UIColor.blue 问题是: 如何获取特定颜色? 我已尝试将UIColor.blue更改为UICo

正如我们所知,我们通过这行代码更改搜索栏的文本颜色,效果良好:

UITextField.appearance(whenContainedInInstancesOf: [UISearchBar.self]).defaultTextAttributes = [NSAttributedStringKey.foregroundColor.rawValue: UIColor.blue]
颜色的占位符是
UIColor.blue

问题是:

如何获取特定颜色?

我已尝试将UIColor.blue更改为UIColor.init(红色:200,绿色:200,蓝色:200,alpha:1)

但是,无论我向
init()
提供多少个红/绿/蓝/阿尔法,我都无法获取颜色

是否存在类似.blue/.red/.yellow的枚举限制


我做错了什么?

请尝试使用UIColor.init而不是UIColor.init

UIColor(red: 100/255, green: 100/255, blue: 100/255, alpha: 1)

请尝试使用UIColor.init而不是UIColor.init

UIColor(red: 100/255, green: 100/255, blue: 100/255, alpha: 1)