我想要一个带有纯色而不是渐变的 UISearchBar。
我有这个:
UISearchBar *mySearchBar = [[UISearchBar alloc] initWithFrame:self.tableView.bounds];
[mySearchBar sizeToFit];
mySearchBar.showsCancelButton = NO;
mySearchBar.tintColor = [UIColor colorWithRed:0.976 green:0.489 blue:0.0824 alpha:1.0];
它给了我一个渐变。我怎样才能把它变成纯色?
如果您的目标是 iOS 5.0 或更高版本,则可以使用 UISearchBarbackgroundImage http://developer.apple.com/library/ios/#documentation/uikit/reference/UISearchBar_Class/Reference/Reference.html财产:
1 点宽的图像或可拉伸图像会被拉伸,
否则图像会平铺。
您还可以在 UISearchBar 外观代理上设置此属性,以便它将应用于整个应用程序中的所有搜索栏:
[[UISearchBar appearance] setBackgroundImage:anImage];
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)