IOS 5 自定义导航条背景图片
2011-11-08 01:23
501 查看
IOS 4的时候:
@implementation UINavigationBar (CustomImage)- (void)drawRect:(CGRect)rect {// Drawing codeUIImage *image = [[UIImage imageNamed:@"header.png"] retain];[image drawInRect:CGRectMake(0, 0,self.frame.size.width , self.frame.size.height)];[image release];}@end
IOS 5以上的代码不会被调用到,上面代码依旧使用,然后加一句以下代码到你的程序委托中:
if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 5.0) {[[UINavigationBar appearance] setBackgroundImage:[UIImage imageNamed:@"bar_nav.jpg"] forBarMetrics:UIBarMetricsDefault];}
这样就支持2种版本了,还有其他方法,比如建个子类。
相关文章推荐
- ios 自定义导航栏背景图片和颜色
- iOS:自定义UItableview背景图片
- 导航条的自定义:背景颜色设置,按钮标题图片设置,图片坐标修改
- iOS开发备忘录:自定义UINavigationBar背景图片和Back按钮
- iOS开发之创建背景透明或含有自定义图片的UIToolbar
- IOS】自定义UIAlertView样式,实现可替换背景和按钮 此博文包含图片此博文包含视频 (2012-10-24 10:23:25)
- iOS 背景图片。按钮高亮自定义背景
- 导航条的自定义:背景颜色设置,按钮标题图片设置,图片坐标修改
- IOS开发中如何自定义导航栏的按钮,文字和背景图片
- iOS自定义控制中心音乐播放 锁屏界面背景图片
- iOS开发备忘录:自定义UINavigationBar背景图片和Back按钮
- IOS 自定义导航栏背景图片和颜色
- IOS 自定义 UIDatePicker 背景图片
- IOS学习 NSNavigationController 自定义:左右按钮、中间文字、背景图片
- ios设置导航条背景图片
- iOS 背景图片。按钮高亮自定义背景
- IOS设置View的背景图片
- 自定义ListCtrl中设置背景图片的问题
- IE7下按钮<input>不显示自定义背景图片
- IE7下按钮<input>不显示自定义背景图片