iOS:如何用一种颜色replacesearch栏背景闪耀/发光
如何从search栏的背景中删除闪光/发光(渐变)。 我想用一种颜色来replace它。
由此:
像这样的东西
使用
searchbar.backgroundImage = //your image here
你可以使用我为uiimage创build的漂亮的类别,它会根据颜色生成一个图片
https://github.com/Hackmodford/HMUIImage-imageWithColor
所以一起看起来就像这样
searchBar.backgroundImage = [UIImage imageWithColor:[UIColor blueColor]];
这将产生你想要的效果。
1删除光面背景:
UISearchBar有UISearchBarBackground类的子视图,只需循环子视图,当你find该类的子视图时,将其alpha设置为0。
RubyMotion示例:
searchBar.subviews.each { |v| v.alpha = 0 if v.class == UISearchBarBackground }
2要添加纯色背景,请覆盖drawRect方法:
RubyMotion示例:
def drawRect(rect) blackColor = '#222222'.to_color context = UIGraphicsGetCurrentContext() CGContextSetFillColor(context, CGColorGetComponents(blackColor.CGColor)) CGContextFillRect(context, rect) end
不要以为你可以,自己尝试一下,它似乎是API的一部分,inheritance人类似的post ,要求同样的事情FB的原因是一个纯色是因为afaik FB应用程序使用Three20框架。 但是,即使所有的尺寸都缩小了,仍然是一个30英尺的大小,对于search栏来说是极端的矫枉过正
甚至不知道如果一个图像将工作,因为你不能设置栏本身周围的区域是清晰或透明的,以将图像放在它下面
- 使用FacebookSDK获取Facebooklogin用户的朋友列表
- 从UICollectionView的viewForSupplementaryElementOfKind获取NSFetchedResultsController节对象
- 我怎样才能正确地将对象从一个Realm对象复制到另一个对象
- Integarte /将cocoapods安装到现有的xcode项目,objective-c或swift
- 故事板从视图控制器到本身
- 一次绘制多个skshapenode?
- iOS模拟器无法安装应用程序
- View Controller在发布后收到一条消息,导致崩溃
- 在Objective-C中呈现来自另一个类的“Controller”