UI2_UINavigationBar
//
// AppDelegate.m
// UI2_UINavigationBar
//
// Created by zhangxueming on 15/7/6.
// Copyright (c) 2015年 zhangxueming. All rights reserved.
// #import "AppDelegate.h" @interface AppDelegate () @end @implementation AppDelegate - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
// Override point for customization after application launch.
UINavigationController *nav = [[UINavigationController alloc] initWithRootViewController:self.window.rootViewController];
self.window.rootViewController = nav; return YES;
}
//
// ViewController.m
// UI2_UINavigationBar
//
// Created by zhangxueming on 15/7/6.
// Copyright (c) 2015年 zhangxueming. All rights reserved.
// #import "ViewController.h"
#import "SubViewController.h" @interface ViewController () @end @implementation ViewController - (void)viewWillAppear:(BOOL)animated
{
[super viewWillAppear:animated];
//获取导航条(视图)
//self.navigationController.navigationBar
//导航条的高度是44(竖屏)
//横屏模式高度是32
NSLog(@"bar = %@", self.navigationController.navigationBar);
NSLog(@"view = %@", self.view); //隐藏导航条
self.navigationController.navigationBar.hidden = YES; //[self.navigationController setNavigationBarHidden:NO animated:NO];
} - (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib. self.view.backgroundColor = [UIColor cyanColor]; //设置背景图片
//人像模式(竖屏) UIBarMetricsDefault,
//风景模式(横屏) UIBarMetricsCompact //图片命名
//普通 navigationBar.png
//高分屏navigationBar@2x.png
//设置了导航条的背景图片后, 对应的视图控制器的视图的高度被发生变化, 竖屏(0, 64) 横屏(0,32) self.navigationController.navigationBar.barStyle = UIBarStyleBlack; self.navigationController.navigationBar.backgroundColor = [UIColor redColor]; self.navigationController.navigationBar.tintColor = [UIColor redColor]; [self.navigationController.navigationBar setBackgroundImage:[UIImage imageNamed:@"navigationBar@2x"] forBarMetrics:UIBarMetricsDefault];
//横屏背景图片
[self.navigationController.navigationBar setBackgroundImage:[UIImage imageNamed:@"navigationBarCompact@2x"] forBarMetrics:UIBarMetricsCompact]; UIButton *btn = [UIButton buttonWithType:UIButtonTypeSystem];
btn.frame = CGRectMake(100, 200, self.view.frame.size.width-200, 50);
[btn setTitle:@"按钮" forState:UIControlStateNormal];
btn.titleLabel.font = [UIFont boldSystemFontOfSize:24];
[btn addTarget:self action:@selector(btnClicked) forControlEvents:UIControlEventTouchUpInside];
[self.view addSubview:btn];
} - (void)btnClicked
{
SubViewController *svc= [[SubViewController alloc] init];
[self.navigationController pushViewController:svc animated:YES];
} - (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
} @end
//
// SubViewController.m
// UI2_UINavigationBar
//
// Created by zhangxueming on 15/7/6.
// Copyright (c) 2015年 zhangxueming. All rights reserved.
// #import "SubViewController.h" @interface SubViewController () @end @implementation SubViewController - (void)viewWillAppear:(BOOL)animated
{
[super viewWillAppear:animated];
NSLog(@"bar = %@", self.navigationController.navigationBar);
NSLog(@"view = %@", self.view);
self.navigationController.navigationBar.hidden = NO; } - (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view.
self.view.backgroundColor= [UIColor yellowColor];
} - (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
} /*
#pragma mark - Navigation // In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
// Get the new view controller using [segue destinationViewController].
// Pass the selected object to the new view controller.
}
*/ @end
UI2_UINavigationBar的更多相关文章
随机推荐
- Android Checkbox Example
1. Custom String 打开 “res/values/strings.xml” 文件, File : res/values/strings.xml <?xml version=&quo ...
- FreeMarker中文API手冊(完整)
FreeMarker概述 FreeMarker是一个模板引擎,一个基于模板生成文本输出的通用工具,使用纯Java编写 FreeMarker被设计用来生成HTML Web页面,特别是基于MVC模式的应用 ...
- OC和JS之间的交互
OC和JS之间的交互 目录 对OC和JS之间交互的理解 JS调用OC OC调用JS 对OC和JS之间交互的理解 JS调用OC JS文件 function sendCommand(cmd,param){ ...
- Ildasm.exe 概要:
一.前言: 微软的IL反编译实用程序——Ildasm.exe,可以对可执行文件(ex,经典的控制台Hello World 的 exe 可执行文件)抽取出 IL 代码,并且给出命名空间以及类的视图.在讲 ...
- 用komodo建立python开发环境
配置 在菜单中选择Edit.Preferences. 代码自动完成 更改tab代表的空格数 括号自动关闭和语法检查 interactive shell 中文支持 缩写 点击菜单View.Tabs &a ...
- 代码片段 - JavaScript 字符串模板
/* ------------------------------ // 字符串模板1,语法严格,不能混用,效率相对较高 // 使用 {{ }} 作为标记是为了允许在模板中使用 JSON 字符串 // ...
- 【PHP代码审计】 那些年我们一起挖掘SQL注入 - 3.全局防护Bypass之Base64Decode
0x01 背景 现在的WEB程序基本都有对SQL注入的全局过滤,像PHP开启了GPC或者在全局文件common.php上使用addslashes()函数对接收的参数进行过滤,尤其是单引号.同上一篇,我 ...
- UML 之 各种视图简介
统一建模语言(Unified Modeling Language,UML)中各种视图并没有明显的概念区别. 在最上一层,视图被划分为三个视图域:结构,动态行为,模型管理. 结构主要描述了系统中的结构成 ...
- Win Mingw-64获取
首先得了解下三种异常不同实现: SJLJ: slower but available for every architecture. SEH: fastest but limited to 64-bi ...
- 自己调用NTDLL函数
一.概述 在DLL初始化的时候有时不能调用其它系统DLL的函数,以免导致问题,但有时候又必须要调用怎么办?一种办法就是自己直接调用NTDLL接口,这样肯定没有问题. 下面我写个自己调用Registry ...