Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/93.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/325.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_Uisearchbar_Uiappearance - Fatal编程技术网

Ios UISearchBar完全自定义背景

Ios UISearchBar完全自定义背景,ios,uisearchbar,uiappearance,Ios,Uisearchbar,Uiappearance,我试图更改UISearchBar的外观以获得以下结果 我尝试了UIAppearance方法,还删除了UISearchBarBackground,但似乎无法删除textfield的边框 我得到的最好结果是: 问题不在于放大镜,而在于边框:)尝试将清晰的颜色设置到搜索栏: [[UISearchBar appearance] setTintColor:[UIColor clearColor]]; 或者尝试: UIImage *searchBg = [UIImage imageNamed:@"Se

我试图更改UISearchBar的外观以获得以下结果

我尝试了UIAppearance方法,还删除了UISearchBarBackground,但似乎无法删除textfield的边框

我得到的最好结果是:


问题不在于放大镜,而在于边框:)

尝试将清晰的颜色设置到搜索栏:

[[UISearchBar appearance] setTintColor:[UIColor clearColor]];
或者尝试:

UIImage *searchBg = [UIImage imageNamed:@"Search_Background.png"];
searchBg = [searchBg stretchableImageWithLeftCapWidth:10 topCapHeight:10]; //experiment with values
 [[UISearchBar appearance] setSearchFieldBackgroundImage: [[UIImage imageNamed: @"background-search"];

您可以发布一些代码吗?您的条形图样式是什么?@KirillProkopovich:条形图样式是默认的,更改为黑色或黑色半透明不会解决我的问题。@PaulPeelen所有操作都是在IB中完成的,除了以下内容:[[UISearchBar外观]setSearchFieldBackgroundImage:[[UIImage ImageName:@“背景搜索”]调整大小的带capinsets的图像:UIEdgeInsetsMake(0,7.0,0,7.0)]用于状态:UIControlStateNormal];如果我的回答对你没有帮助。我为搜索提供了UseJustTextField,它是任何UIImageView(后台)的子视图。您可以找到搜索专用的文本字段不,它不起作用,这是我用清晰的颜色获得的:setBackgroundImage本身并不能解决问题,但这和setSearchFieldBackgroundImage对搜索栏起作用。我现在得检查一下示波器,一切都正常。谢谢Kirill,如果您能在回答中添加“setSearchFieldBackgroundImage:)