Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/xcode/7.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_Xcode_Swift_Uisearchbar - Fatal编程技术网

Ios 在Swift中激活时更改搜索栏颜色

Ios 在Swift中激活时更改搜索栏颜色,ios,xcode,swift,uisearchbar,Ios,Xcode,Swift,Uisearchbar,所以我现在使用的是一个基本的搜索栏。看起来像这样 当它激活时,看起来是这样的 因此,我的问题是如何使活动搜索栏/导航栏也变成绿色。但当它不活动时,返回默认值。我做了一些研究。但迄今为止,还没有什么能激发出解决方案。有什么想法吗?顺便说一句,我在Swift工作。您试用过Swift的功能吗。在相应函数中更改UISearchBars BartinColor应该可以完成这项工作。我有,但它也会更改非活动栏@iLenweYou,例如,使用func searchbar shouldbegineditings

所以我现在使用的是一个基本的搜索栏。看起来像这样

当它激活时,看起来是这样的


因此,我的问题是如何使活动搜索栏/导航栏也变成绿色。但当它不活动时,返回默认值。我做了一些研究。但迄今为止,还没有什么能激发出解决方案。有什么想法吗?顺便说一句,我在Swift工作。

您试用过Swift的功能吗。在相应函数中更改UISearchBars BartinColor应该可以完成这项工作。我有,但它也会更改非活动栏@iLenweYou,例如,使用func searchbar shouldbegineditingsearchbar:UISearchBar->Bool将导航栏和搜索栏barTintColor更改为绿色,并使用类似func searchbar searchbuttonclickedsearchbar:UISearchBar{searchbar.barTintColor=nil navbar.barTintColor=nil self.view.endeditingrue}将bartincolor更改回灰色。因此,每当用户点击搜索字段时,搜索和导航栏都将为绿色,当用户按下搜索按钮时,颜色将变回默认颜色。