- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
//1、创建窗口
self.window = [[UIWindowalloc]initWithFrame:[[UIScreenmainScreen]bounds]];
self.window.backgroundColor = [UIColorwhiteColor];
//2.创建一个导航控制器并添加子视图
UINavigationController *nav = [[UINavigationControlleralloc]initWithRootViewController:[ViewControllernew]];
//nav.navigationBar.barTintColor = [UIColor redColor];
[nav.navigationBarsetBackgroundImage:[UIImageimageNamed:@"00"]forBarMetrics:UIBarMetricsDefault];
//3.设置根视图
self.window.rootViewController = nav;
//4、显示窗口
[self.windowmakeKeyAndVisible];
return YES;
}
- (void)viewDidLoad {
[super viewDidLoad];
//定制标题
//方式2:
UILabel *titleLab = [[UILabelalloc]initWithFrame:CGRectMake(0,20, 80, 44)];
titleLab.text =@"通讯录";
titleLab.textColor = [UIColorwhiteColor];
titleLab.textAlignment =NSTextAlignmentCenter;
self.navigationItem.titleView = titleLab;
//定制右按钮
UIButton *but = [UIButtonbuttonWithType:UIButtonTypeCustom];
but.frame =CGRectMake(0,0, 60, 44);
[but setTitle:@"下一页"forState:UIControlStateNormal];
[but addTarget:selfaction:@selector(Next:)forControlEvents:UIControlEventTouchUpInside];
UIBarButtonItem *barBut = [[UIBarButtonItemalloc]initWithCustomView:but];
self.navigationItem.rightBarButtonItem = barBut;
//定制左按钮
UIButton *but = [UIButtonbuttonWithType:UIButtonTypeCustom];
but.frame =CGRectMake(0,0, 60, 44);
[but setTitle:@"<返回"forState:UIControlStateNormal];
[but addTarget:selfaction:@selector(popView:)forControlEvents:UIControlEventTouchUpInside];
UIBarButtonItem *barBut = [[UIBarButtonItemalloc]initWithCustomView:but];
self.navigationItem.leftBarButtonItem = barBut;
//左按钮事件响应函数
-(IBAction)Next:(id)sender{
}
//右按钮事件响应函数
-(IBAction)popView:(id)sender{
}