//
// 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的更多相关文章

随机推荐

  1. c#(asp.net)杂谈笔记

    1.js解析json格式的时间 //转换json格式时间的方法 如Date(1340239979000)转换为正常 function ConvertJSONDateToJSDateObject(JSO ...

  2. innodb 变量

    http://dev.mysql.com/doc/refman/5.7/en/innodb-parameters.html

  3. windows下查看某个端口被哪个程序占用的方法

    经常,我们在启动应用的时候发现系统需要的端口被别的程序占用,如何知道谁占有了我们需要的端口,很多人都比较头疼,下面就介绍一种非常简单的方法,希望对大家有用 假如我们需要确定谁占用了我们的9050端口 ...

  4. php模拟多线程

    一:应该知道的: php本身是不支持多线, 但是php的好搭档,apache和linux是支持的,故lamp才是最佳组合,还在使用win服务器的现在知道为什么要用linux吧.既然是模拟的, 就不是真 ...

  5. C#实现万年历(农历、节气、节日、星座、属相、生肖、闰年等)

    C# 万年历 农历 节气 节日 星座 星宿 属相 生肖 闰年月 时辰等,代码如下: using System.Collections.Generic; using System.Text; using ...

  6. BootStrap2学习日记23---图片轮播

    <div id="carousel1" class="carousel slide"> <div class="carousel-i ...

  7. jQuery ajax - ajax() 方法

    1.jsp页面 function onSaveClick(btn) {//保存 $.ajax({ url : "" , type : "POST", data ...

  8. TF-IDF算法扫盲2

    TF-IDF算法是一种简单快捷的文档特征词抽取方法,通过统计文档中的词频来对文档进行主题分类.TF-IDF(term frequency–inverse document frequency)是一种统 ...

  9. PetaPOCO 一对多 多对一 多对多

    PetaPoco支持将结果集中的一行映射到到两个以及更多POCO,但是如何处理一对多和多对多关系? 1.PetaPoco 支持将结果映射为多个POCO类型,提供了另一种方法来处理SQL的Join查询. ...

  10. ASUS K751笔记本电脑使用U盘启动

    ASUS K751笔记本电脑缺省是不能使用U盘启动的.即使开机按ESC键出现启动设备选项菜单,选择了U盘也一样会从硬盘启动. 为此需进行如下步骤: 开机按F2进入bios如下设置: Security- ...