UINavigationBar自定义导航栏
来源:互联网 发布:软件项目付款比例 编辑:程序博客网 时间:2024/05/17 23:14
UINavigationBar自定义导航栏背景和按钮,完美支持横屏竖屏旋转,视图控制器可以分别使用自己的导航栏
此方法可以通过Apple审核,导航上的按钮背景需要做,否则看起来不那么和之又谐
- //CustomNavigationBar.h
- @interface UINavigationBar (UINavigationBarCategory)
- UIImageView *backgroundView;
- - (void)setBackgroundImage:(UIImage*)image;
- - (void)insertSubview:(UIView *)view atIndex:(NSInteger)index;
- @end
- //CustomNavigationBar.m
- @implementation UINavigationBar (UINavigationBarCategory)
- -(void)setBackgroundImage:(UIImage*)image
- {
- if(image == nil)
- {
- [backgroundView removeFromSuperview];
- }
- else
- {
- backgroundView = [[UIImageView alloc] initWithImage:image];
- backgroundView.tag = 1;
- backgroundView.frame = CGRectMake(0.f, 0.f, self.frame.size.width, self.frame.size.height);
- backgroundView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
- [self addSubview:backgroundView];
- [self sendSubviewToBack:backgroundView];
- [backgroundView release];
- }
- }
- //for other views
- - (void)insertSubview:(UIView *)view atIndex:(NSInteger)index
- {
- [super insertSubview:view atIndex:index];
- [self sendSubviewToBack:backgroundView];
- }
- @end
- //YourViewController.m
- - (void)viewWillAppear:(BOOL)animated
- {
- [super viewWillAppear:animated];
- [self.navigationController.navigationBar
- setBackgroundImage:[UIImage imageNamed:@"navigation_bar_bg.png"]];
- }
//CustomNavigationBar.h@interface UINavigationBar (UINavigationBarCategory)UIImageView *backgroundView;- (void)setBackgroundImage:(UIImage*)image;- (void)insertSubview:(UIView *)view atIndex:(NSInteger)index;@end//CustomNavigationBar.m@implementation UINavigationBar (UINavigationBarCategory)-(void)setBackgroundImage:(UIImage*)image{if(image == nil){[backgroundView removeFromSuperview];}else{backgroundView = [[UIImageView alloc] initWithImage:image];backgroundView.tag = 1;backgroundView.frame = CGRectMake(0.f, 0.f, self.frame.size.width, self.frame.size.height);backgroundView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;[self addSubview:backgroundView];[self sendSubviewToBack:backgroundView];[backgroundView release];}}//for other views- (void)insertSubview:(UIView *)view atIndex:(NSInteger)index{[super insertSubview:view atIndex:index];[self sendSubviewToBack:backgroundView];}@end//YourViewController.m- (void)viewWillAppear:(BOOL)animated{[super viewWillAppear:animated];[self.navigationController.navigationBarsetBackgroundImage:[UIImage imageNamed:@"navigation_bar_bg.png"]];}
- UINavigationBar自定义导航栏
- 自定义导航栏UINavigationBar
- 45.自定义导航栏 UINavigationBar
- UINavigationBar自定义导航栏背景和按钮
- UINavigationBar自定义导航栏背景…
- UINavigationBar自定义导航栏背景和按钮
- 导航栏: UINavigationBar用法
- UInavigationBar自定义导航栏背景和按钮(二)
- ios5 自定义导航条问题 UINavigationBar
- ios5 自定义导航条问题 UINavigationBar
- ios5 自定义导航条问题 UINavigationBar
- UINavigationBar导航栏相关设置
- UINavigationBar导航栏相关设置
- UINavigationController导航控制器 UINavigationBar导航栏
- 导航栏(UINavigationBar类与UINavigationBarDelegate协议)
- iOS开发 导航栏 UINavigationBar 属性
- IOS UINavigationBar 导航栏 全局样式设置
- iOS 隐藏导航栏UINavigationBar底部黑线
- The 2012 Web Application Scanner Benchmark has been Published
- WS-Attacker v.1.1 Released
- gui输入法设计
- maven学习
- JAVA中throw和throws的区别
- UINavigationBar自定义导航栏
- Setup SS5 Socks Proxy
- arcgis10.0 sp5下载
- ELF文件的格式和加载过程
- poj 1066 Treasure Hunt(判断线段相交)
- 一些开源项目
- SeekBar控件
- Oracle 数据类型及存储方式
- 修改tomcat 发布war大小限制