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的更多相关文章
随机推荐
- Docker:使用Ambassador进行跨主机间容器通信
转载请注明出处:点我 由于Docker自身的网络的原因,想要在多主机间的容器之间进行通信是比较麻烦的事情.可以利用Ambassador容器来实现这一功能. 基本原理: 利用Ambassador来实现主 ...
- window.showModalDialog 与window.open传递参数的不同?
简单的说,就是一个在弹出窗口之后可以做其它的事,即window.open 另一个在弹出窗口之后不能做其它的事,只能是关闭了当前的窗口之后才能做其它的事,即window.showModalDialog ...
- Java对证书的操作
1 Java程序从证书文件读取证书 import java.io.*; import java.security.cert.*; public class PrintCert{ public stat ...
- centos 安装git server
1.yum install lrzsz wget git 2.安装gitosis:gitosis为Git用户权限管理系统,通过管理服务端的/home/git/.ssh/authorized_key文件 ...
- Flex博客
http://blog.csdn.net/xingfeng0501/article/details/7533426
- P、NP、NP-Complete、NP-hard问题
Table of Contents 1 遇到难题怎么办? 2 什么是P.NP.NP-Complete和NP-hard 3 P = NP ???? 4 参考 1 遇到难题怎么办? 遇到一个问题,通常我们 ...
- j疑难杂症:java.lang.VerifyError: class org.hibernate.type.WrappedMaterializedBlobType overrides final method getReturnedClass.()Ljava/lang/Class;
问题: java.lang.VerifyError: class org.hibernate.type.WrappedMaterializedBlobType overrides final meth ...
- postgres函数
1.数据修复最先考虑通过db内做修复,实在不行,在考虑外部应用程序通过jdbc修复. 比如一个场景:profile_image_url与enlarge_image_url都是微博用户信息返回的字段. ...
- IOS 开发中判断NSString是否为空字符
//当 请求网络 或者获取其他返回数据 首先 要做一次判断 数据是否为空 防止程序崩溃 程序崩溃 好比拿刀扎在程序员的心啊- if(为空) { 做提示对话框等操作 } else { 正常执行 } - ...
- WebApi 部署后一直返回404的解决办法
Fixing ASP.NET MVC 4 Web API 404 Posted on November 5, 2012 For a Web Service providing some REST-st ...