iOS学习UI之UINavigationController

UINavigationbar
1、获取导航栏
UINavigationBar* bar =
self.navigationController.navigationBar;
2、导航栏样式 barStyle
self.navigationController.navigationBar.barStyle = UIBarStyleDefault;
3、设置导航栏的颜色 barTintColor
self.navigationController.navigationBar.barTintColor = [UIColor redColor];
4、设置barbutton颜色 tintColor
self.navigationController.navigationBar.tintColor = [UIColor greenColor];
5、设置导航栏的透明度 translucent
self.navigationController.navigationBar.translucent = NO;
6、设置导航栏的图片
@params UIimage 图片
@params BarMetrics 图片的横竖样式
//竖屏模式:人像模式 UIBarMetricsDefault
//横屏模式:风景模式 UIBarMetricsCompact
[self.navigationController.navigationBar setBackgroundImage:[UIImage imageNamed:@”navigationbar.png”] forBarMetrics:UIBarMetricsDefault];
NavigationItem
1、设置标题方式 1 title
self.title = @”title”;
2、设置标题方式2
self.navigationItem.title = @”title”;
3、自定义标题头
self.navigationItem.titleView = [UIView myview];
UIBarButtonItem的实例化
1、文字类型初始化
UIBarButtonItem* titleBtn = [[UIBarButtonItem alloc] initWithTitle:@”我自定义的” style:UIBarButtonItemStylePlain target:self action:@selector(barBtnClick:)];
2、图片类型初始化
UIImage* image = [[UIImage imageNamed:@”ImageName.png”]imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
UIImageRenderingMode 图片渲染模式,默认为蓝色
UIBarButtonItem* imageItem = [[UIBarButtonItem alloc] initWithImage:image style:UIBarButtonItemStylePlain target:self action:@selector(BarbtnClick)];
3、系统类型初始化
UIBarButtonItem* sysytem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemDone target:self action:@selector(barBtnClick:)];
4、自定义
UIView* view = [[UIView alloc] init];
UIBarButtonItem* custom = [[UIBarButtonItem alloc] initWithCustomView:view];
5、设置左按钮 leftBarButtonItem
self.navigationItem.leftBarButtonItem =customButton;
6、设置做按钮集 leftBarButtonItems
self.navigationItem.leftBarButtonItems = arr;
7、设置右按钮
self.navigationItem.rightBarButtonItem = titleButton;
8、设置右按钮集
self.navigationItem.rightBarButtonItems = arr;
UIToolbar
1、设置工具条是否隐藏
self.navigationController.toolbarHidden = NO;
2、获取工具条
UIToolbar* tool = self.navigationController.toolbar;
3、设置样式 barStyle
tool.barStyle = UIBarStyleBlack;
4、设置颜色 barTintColor
tool.barTintColor = [UIColor purpleColor];
5、设置背景
[tool setBackgroundImage:[UIImage imageNamed:@”toolBar.png”] forToolbarPosition:UIBarPositionAny barMetrics:UIBarMetricsDefault];
6、创建系统空格
UIBarButtonItem *space = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace target:self action:@selector(attack:)];
7、设置工具条的按钮
self.toolbarItems = @[btn1,space,btn2,space,btn3];
8、自定义toolbar
UIToolbar *toolBar = [[UIToolbar alloc] initWithFrame:CGRectMake(0,
200, 300, 44)];
toolBar.tintColor = [UIColor redColor];
toolBar.items = @[space,btn2,space];
[self.view addSubview:toolBar];

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值