码迷,mamicode.com
首页 > 其他好文 > 详细

UINavigationController的navigationBar的常用设置(按钮,标题,颜色)

时间:2015-05-11 17:57:04      阅读:167      评论:0      收藏:0      [点我收藏+]

标签:uinavigationcontroll

http://blog.csdn.net/u010229677白白手游专栏

使用:

    ViewController* vc = [[ViewController alloc] init];    
    self.window.rootViewController = [[UINavigationController alloc] initWithRootViewController:vc];
    self.window.backgroundColor = [UIColor whiteColor];
    [self.window makeKeyAndVisible];


切换:

[self.navigationController pushViewController:xxx animated:YES];

[self.navigationController popViewControllerAnimated:YES];

    self.title = @"标题";    
    //设置背景颜色,下面三句话
    self.navigationController.navigationBar.backgroundColor = [UIColor blueColor];
    self.navigationController.navigationBar.translucent = YES; //设置背景为透明的
    self.navigationController.navigationBar.barStyle = UIBarStyleBlack;
    
    self.navigationController.navigationBar.tintColor = [UIColor blueColor]; //设置按钮颜色
    //手动添加左右两个按钮,若不添加,左按钮自动生成,带有返回图标和上一个界面的标题
    UIBarButtonItem *backButton = [[UIBarButtonItem alloc] initWithTitle:@"Exit" style:UIBarButtonItemStylePlain target:self action:@selector(handleExit:)];
    self.navigationItem.leftBarButtonItem = backButton;
    UIBarButtonItem *setButton = [[UIBarButtonItem alloc] initWithTitle:@"设置" style:UIBarButtonItemStylePlain target:self action:@selector(setButtonAction:)];
    self.navigationItem.rightBarButtonItem = setButton;


UINavigationController的navigationBar的常用设置(按钮,标题,颜色)

标签:uinavigationcontroll

原文地址:http://blog.csdn.net/u010229677/article/details/45645869

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!