相关疑难解决方法(0)

如何在iOS上更改UISearchBar组件的内部背景颜色

我知道如何删除/更改UISearchBar搜索字段周围的背景颜色:

[[self.searchBar.subviews objectAtIndex:0] removeFromSuperview];
self.searchBar.backgroundColor = [UIColor grayColor];
Run Code Online (Sandbox Code Playgroud)

实现了UISearchBar定制

但是不知道如何在里面这样做:

期望的UISearchBar定制

这需要与iOS 4.3+兼容.

customization objective-c background-color uisearchbar ios

61
推荐指数
14
解决办法
7万
查看次数

我正在尝试将背景图像设置为UISearchBar,但背景图像未在我的iPhone应用程序中显示

在我的iPhone应用程序中,我正在尝试将背景图像设置为UISearch Bar,我的图像未显示.

这是我的代码

UISearchBar * tempSearchBar = [[UISearchBar alloc] initWithFrame:CGRectMake( 0, 0, self.view.bounds.size.width, 40 )];

self.searchBar = tempSearchBar;
tempSearchBar.delegate = self; 
self.searchBar.autocorrectionType = UITextAutocorrectionTypeNo;
self.searchBar.autocapitalizationType = UITextAutocapitalizationTypeNone;
self.searchBar.barStyle = UIBarStyleBlack;
self.searchBar.backgroundColor=[UIColor clearColor];
self.searchBar.backgroundImage=[UIImage imageNamed:@"Searchbox.png"];
self.searchBar.placeholder = @"Search My Data";
[self.searchBar sizeToFit];  

[self.view addSubview:self.searchBar];
[tempSearchBar release];
Run Code Online (Sandbox Code Playgroud)

background uiimageview uisearchbar ios

0
推荐指数
1
解决办法
4057
查看次数