UISearchBar纯色 [英] UISearchBar solid color

查看:121
本文介绍了UISearchBar纯色的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想要一个纯色而不是渐变的UISearchBar。

I would like to have a UISearchBar with a solid color rather than a gradient.

我有这个:

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];

它给了我一个渐变。如何使其成为纯色?

And it gives me a gradient. How can I make it a solid color?

推荐答案

如果您的目标是iOS 5.0或更高版本,则可以使用UISearchBar backgroundImage 属性:

If you are targeting iOS 5.0 or later, you can use the UISearchBar backgroundImage property:


1个点宽的图像或可拉伸的图像被拉伸,
否则图像是平铺。

Images that are 1 point wide or stretchable images are stretched, otherwise the image is tiled.

您还可以在UISearchBar外观代理上设置此属性,以便它适用于整个应用中的所有搜索栏: / p>

You can also set this property on the UISearchBar appearance proxy so that it will apply to all search bars throughout your app:

[[UISearchBar appearance] setBackgroundImage:anImage];

这篇关于UISearchBar纯色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆