UINavigationBar 和 UINavigationItem的属性设置
#import "RootViewController.h"
@interface RootViewController ()
@end
@implementation RootViewController
- (void)viewDidLoad {
[super viewDidLoad];
self.view.backgroundColor = [UIColor orangeColor];
// 布局导航控制器
[self initLayout];
}
- (void)initLayout {
// 导航控制器的显示和隐藏
self.navigationController.navigationBarHidden = NO;
#pragma mark - UINavigationBar(导航条)
// 设置导航条是否开启半透明效果
// ios7.0之后,半透明效果默认是打开的,当半透明效果开启时,self.view以屏幕左上角为坐标原点,关闭时,导航条左下角为坐标原点。
self.navigationController.navigationBar.translucent = NO;
// UIView *view = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 100, 100)];
// view.backgroundColor = [UIColor cyanColor];
// [self.view addSubview:view];
// 修改导航条颜色
self.navigationController.navigationBar.barTintColor = [UIColor blackColor];
// self.navigationController.navigationBar.backgroundColor = [UIColor redColor]; // 修改背景颜色不能完成修改导航条颜色
// 设置导航元素的颜色(item上按钮的颜色)
self.navigationController.navigationBar.tintColor = [UIColor whiteColor];
// 导航栏样式
self.navigationController.navigationBar.barStyle = UIBarStyleBlack; // 系统只有两种样式
// 设置导航条标题
self.title = @"根视图";
#pragma mark - navigationTtem属性
self.navigationItem.title = @"根视图"; // 也可以设置导航条标题
// 左按钮
self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:@"左按钮" style:UIBarButtonItemStylePlain target:self action:@selector(leftItemAction:)];
// 右按钮
// self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemCancel target:self action:@selector(rightItemClick:)];
// self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithImage:[UIImage imageNamed:@"222.png"] style:UIBarButtonItemStylePlain target:self action:@selector(rightItemClick:)];
// 某一边添加多个按钮,可以用rightBarButtonItems来添加多个,先创建多个按钮,再用数组的形式添加
UIBarButtonItem *item1 = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemAdd target:self action:@selector(rightItemClick:)];
UIBarButtonItem *item2 = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemBookmarks target:self action:@selector(rightItemClick:)];
self.navigationItem.rightBarButtonItems = @[item1, item2];
// 标题视图
UISegmentedControl *segment = [[UISegmentedControl alloc] initWithItems:@[@"卫庄", @"盖聂"]];
//segment.frame = CGRectMake(0, 0, 100, 30); // 位置是固定的,设置frame并没有用
// 修改标题视图
self.navigationItem.titleView = segment;
}
// 实现方法
- (void)leftItemAction:(UIBarButtonItem *)sender {
NSLog(@"左按钮");
}
- (void)rightItemClick:(UIBarButtonItem *)sender {
NSLog(@"右按钮");
}
UINavigationBar 和 UINavigationItem的属性设置的更多相关文章
- WinForm------DateEdit属性设置
1.只能选择年份属性设置
- Composer Player 属性设置
/// <summary> /// 设置选中名称 /// </summary> /// <param name="name"></para ...
- table中bordercolor属性设置后最新ie浏览器或firefox中不显示边线,借助table的css来实现边线
table中的bordercolor属性设置后在最新的ie或者firefox中均不显示边线,table的边线又是常用功能.只能使用css来实现了,更通用,更方便一些. css: .ctable{ b ...
- .net 使用Json(),maxJsonLength属性设置的值问题
“使用JSON JavaScriptSerializer进行序列化或反序列化时出错.字符串的长度超过了为maxJsonLength属性设置的值” 今天业务找我说线上的国家地区都显示数字(地区ID),而 ...
- DEV控件:gridControl常用属性设置(转载)
特别长,先撸下来再说 1.隐藏最上面的GroupPanel gridView1.OptionsView.ShowGroupPanel=false; 2.得到当前选定记录某字段的值 sValue=T ...
- Appium学习实践(二)Python简单脚本以及元素的属性设置
1.简单的Python脚本 Appium中的设置与Appium学习实践(一)简易运行Appium中的一致 Launch后,执行脚本 #coding:utf-8 import unittest impo ...
- DEV控件:gridControl常用属性设置
1.隐藏最上面的GroupPanel gridView1.OptionsView.ShowGroupPanel=false; 2.得到当前选定记录某字段的值 sValue=Table.Rows[g ...
- [转]浅谈jQuery EasyUI的属性设置
原文地址:http://www.easyui.info/archives/1664.html 对jQuery EasyUI有一定了解的话,应该知道基本上每一个组件都有一个"options&q ...
- DEV控件GridControl常用属性设置
1. 如何解决单击记录整行选中的问题 View->OptionsBehavior->EditorShowMode 设置为:Click 2. 如何新增一条记录 (1).gridView.Ad ...
随机推荐
- Second Level Cache for Entity Framework 6.1
Second Level Cache for Entity Framework 6.1 Entity Framework does not currently support caching of q ...
- smartjs 0.2发布 - 新增oop模块&AOP增强
SmartJS2.0发布,更新内容如下: 新增oop(klass,factory)模块: promiseEvent加入非阻塞模式noBlock: trigger加入属性监听; smartjs主模块优化 ...
- transactional replication 的immediate_sync属性
在默认情况下,immediate_sync是关闭的,这个属性可以在创建publication时指定,也可以在创建完毕后修改. 如果immediate_sync为true, snapshot 文件和re ...
- 数据可视化(5)--jqplot经典实例
本来想把实例也写到上篇博客里,最后发现太长了,拆成两篇博客了. 实例来源于官方文档:http://www.jqplot.com/tests/ 这篇博客主要是翻译了官方文档关于经典实例的解说,并在相应代 ...
- [OpenCV] Install openCV in Qt Creator
Learn openCV.pdf qmake: link with opencv (Key Point) QT += core gui greaterThan(QT_MAJOR_VERSION, 4) ...
- Bucky – 免费开源的实时用户监控工具
Bucky 是一个开源的实时用户监控工具,用于衡量用户在浏览器中使用 Web 应用程序时的性能.它可以自动测量你的网页需要多长时间来加载,Ajax 请求需要多长时间和各个函数需要实行多久. 您可能感兴 ...
- 邮箱mail 发送类 ASP.NET C#
没有牛B的设计模式,代码精练精练实用,功能齐全,调用简单 ..全全完完为码农考虑 MailSmtp ms = new MailSmtp("smtp.qq.com","12 ...
- .NET框架面向对象分层的个人想理
简单.层次清晰不要过度优化,接口这玩意儿就是个双刃剑,玩好了解藕,玩不好自找麻烦,好的代码永远都是傻瓜都能看懂的. 总结成以下几条: 公用层 代码公用并且与第三方DLL和业务逻辑无关的 独立出来 逻辑 ...
- Main.storyboard中使用navigationController
传统使用navigationController的创建是在appdelegate中,使用storyboard的话必须在Main.storyboard文件中创建. 1.选中创建的navigationCo ...
- VS2010 根据模型生成数据库 打开edmx.sql文件时 vs出现无响应的解决方案
今天在VS2010 sp1+sql server 2008 R2+Win7操作系统下测试ADO.NET 实体数据模型时 ,遇到这样一个问题. 首先建好实体模型,然后"根据模型生成数据库&qu ...