UINavgationController
2016-02-17 13:20
393 查看
UINavigationBar和
UINavigationItem是iOS开发中常用的控件。
1.设置导航栏标题
self.title = @"iOS开发:iOSDevTip";
[/code]
2.设置导航栏样式
设置方法:[self.navigationController.navigationBar setBarStyle:UIBarStyleBlack];
[/code]
UIBarStyle的样式:
typedef NS_ENUM(NSInteger, UIBarStyle) { UIBarStyleDefault = 0, UIBarStyleBlack = 1, UIBarStyleBlackOpaque = 1, // Deprecated. Use UIBarStyleBlack UIBarStyleBlackTranslucent = 2, // Deprecated. Use UIBarStyleBlack and set the translucent property to YES };
[/code]
UIBarStyleDefault是默认样式,
UIBarStyleBlack是黑色不透明。
UIBarStyleBlackOpaque和
UIBarStyleBlackTranslucent这两个已经废弃了。
如果想设置导航栏透明,可以加上下面这句代码:
self.navigationController.navigationBar.translucent = YES;
[/code]
3.修改返回按钮title
self.navigationItem.title = @"test";
[/code]
4.隐藏返回按钮title
比较笨的方法是:self.navigationItem.title = @"";
[/code]
还可以这样设置:
[[UIBarButtonItem appearance] setBackButtonTitlePositionAdjustment:UIOffsetMake(0, -60) forBarMetrics:UIBarMetricsDefault];
[/code]
5.设置leftBarButtonItem
self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:@"back" style:UIBarButtonItemStylePlain target:self action:@selector(back:)]; - (void)back:(id)sender { [self.navigationController popViewControllerAnimated:YES]; }
[/code]
6.左滑返回手势失效了怎么办
如果按上一步设置leftBarButtonItem之后,左滑返回手势就会失效。设置一下
UIGestureRecognizerDelegate代理即可:
self.navigationController.interactivePopGestureRecognizer.delegate = self;
相关文章推荐
- AndroidStudioTutorial_160217S001_简单UI
- UIControlEvent
- UICollectionView实现无限轮播
- iOS 解决页面按钮同时点击,同时触发问题 设置所有UIButton的ExclusiveTouch属性为YES
- HDU 1159:Common Subsequence
- java建造者模式(Builder)
- UIToolBar的使用
- 学习UITextField忽略掉的细节
- [leetcode] 334. Increasing Triplet Subsequence
- Qt使用教程之使用Qt Quick UI表单(二)
- 2016太原UI设计师告你去公司我们涉猎哪些工作?
- ios UIAlertController
- Sublime Text 3 build 3103 license 四个供研究使用
- Map(key,value)
- poj 2031 Building a Space station(prim)
- UIBezierPath 绘制正五边形
- easyui 表单元素验证
- easyUI 验证
- NSURL、NSURLRequest、NSURLSession和NSURLSessionTask
- UIBezierPath和CAShapeLayer 阅读笔记