iOS导航条和工具条
来源:互联网 发布:淘宝基础班导航条全屏 编辑:程序博客网 时间:2024/06/05 02:08
设置导航条上方是否留出(信号,电池的空隙)
self.navigationController.navigationBar.clipsToBounds =YES;
导航条的的样式:navigationBar.barStyle
self.navigationController.navigationBar.barStyle = UIBarStyleBlackTranslucent;
导航条的背景图(基于导航控制器的,不会压缩图片):navigationBar setBackgroundImage...
[self.navigationController.navigationBar setBackgroundImage:[UIImage imageNamed:@"people_caoying.png"] forBarMetrics:UIBarMetricsDefault];
自定义导航条的左右文字按钮:UIBarButtonItem
self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:@"左按钮" style:UIBarButtonItemStylePlain target:self action:@selector(clickLeft)];
系统自带的导航条的左右文字按钮(一大堆:编辑,保存,返回.....)
self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemEdit target:self action:nil];
设置当前视图的控制器的返回按钮,在下个界面生效
self.navigationItem.backBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:@"gs" style:UIBarButtonItemStylePlain target:self action:nil];
隐藏返回按钮
self.navigationItem.hidesBackButton = YES;
导航栏的左右图片按钮
UIButton *buttonRight = [UIButton buttonWithType:UIButtonTypeCustom];
buttonRight.frame = CGRectMake(0, 0, 40, 40);
[buttonRight setBackgroundImage:[UIImage imageNamed:@"press.png"] forState:UIControlStateNormal];
self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:buttonRight];
导航栏的视图标题:navigationItem.titleView(视图标题)(会压缩图片,全部显示上去)
UIImageView *imageView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 20, 40)];
imageView.image = [UIImage imageNamed:@"people_caoying.png"];
self.navigationItem.titleView = imageView;
同时添加多个导航条按钮
UIBarButtonItem *item1 = [[UIBarButtonItem alloc]initWithTitle:@"第一" style:UIBarButtonItemStyleDone target:self action:nil];
UIBarButtonItem *item2 = [[UIBarButtonItem alloc]initWithTitle:@"第二" style:UIBarButtonItemStyleDone target:self action:nil];
UIView *view = [[UIView alloc]initWithFrame:CGRectMake(0, 0, 30, 40)];
view.backgroundColor = [UIColor orangeColor];
UIBarButtonItem *item3 = [[UIBarButtonItem alloc]initWithCustomView:view];
self.navigationItem.leftBarButtonItems = @[item1, item2, item3];
为导航栏添加视图标题titleview
UILabel *lable = [[UILabel alloc]initWithFrame:CGRectMake(0, 0, 40, 40)];
lable.text = @"自定义";
lable.textColor = [UIColor redColor];
lable.backgroundColor = [UIColor yellowColor];
lable.textAlignment = NSTextAlignmentCenter;
self.navigationItem.titleView = lable;
统一修改toolbar元素颜色
[[UIToolbar appearance]setTintColor:[UIColor yellowColor]];
让toolbar显示
self.navigationController.toolbarHidden =NO;
修改toolbar的风格
self.navigationController.toolbar.barStyle = UIBarStyleBlack;
创建多个UIBarButtonItem 添加到工具栏
UIBarButtonItem *item = [[UIBarButtonItem alloc]initWithTitle:@"红色" style:UIBarButtonItemStylePlain target:self action:nil];
UIBarButtonItem *item2 = [[UIBarButtonItem alloc]initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace target:self action:nil];
UIBarButtonItem *item4 = [[UIBarButtonItem alloc]initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace target:self action:nil];
self.toolbarItems =@[item,item2,item4];
- iOS导航条和工具条
- iOS_导航条和工具条的基本用法
- iOS 9 隐藏导航条和状态栏
- iOS 9 隐藏导航条和状态栏
- VC2010抽屉工具条,OutlookBar导航条无法显示的问题
- WORD的工具条和菜单条消失
- ios改变导航条title的字体大小和颜色
- iOS改变UINavigationBar导航条标题颜色和字体
- iOS开发---改变UINavigationBar导航条标题颜色和字体
- ios改变导航条title的字体大小和颜色
- iOS----改变导航条title的字体大小和颜色
- ios 导航条消失 navigationBar.hidden 和 navigationBarHidden 区别
- [iOS 自定义导航栏/导航条]隐藏系统导航条
- 按钮和导航条
- ios导航条添加按钮
- ios设置导航条背景图片
- ios导航条添加按钮
- iOS 导航条背景透明
- 使用VS2010调用QtDesigner设计的UI文件,并实现控件功能
- Linux下搭LNMP
- 关于使用Git&Bitbucket的一些Tips
- Android Animation之补间动画
- 参加微软黑客马拉松经历
- iOS导航条和工具条
- ZOJ 3652Maze
- VS插件-GetSet生成器
- Linux下进行SVN迁移
- iOS开发:设计模式那点事
- Intellij IDEA & Android Studio IDE自己风格的配置
- Spark standalone集群安装
- Android.view.inflateException :binary xml file line #2:Error inflating class
- 第一个Blog