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

导航控制器--NavgationController

时间:2015-02-28 16:10:48      阅读:100      评论:0      收藏:0      [点我收藏+]

标签:

//此方法只会调用一次,设置UIBarButtonItem样式
+(void)initialize
{
    //通过appearance对象能修改整个项目中所有UIBarButtonItem的样式
    UIBarButtonItem *appearance = [UIBarButtonItem appearance];

    //1.普通状态
    NSMutableDictionary *textAttrs = [NSMutableDictionary dictionary];
    textAttrs[UITextAttributeTextColor] = [UIColor orangeColor];
    textAttrs[UITextAttributeFont] = [UIFont systemFontOfSize:15];
    [appearance setTitleTextAttributes:textAttrs forState:UIControlStateNormal];
    
    //2.高亮状态
    NSMutableDictionary *highAttrs = [NSMutableDictionary dictionary];
    highAttrs[UITextAttributeTextColor] = [UIColor redColor];
    highAttrs[UITextAttributeFont] = [UIFont systemFontOfSize:15];
    [appearance setTitleTextAttributes:highAttrs forState:UIControlStateHighlighted];
    
    //3.不可点击状态
    NSMutableDictionary *disAttrs = [NSMutableDictionary dictionary];
    disAttrs[UITextAttributeTextColor] = [UIColor lightGrayColor];
    disAttrs[UITextAttributeFont] = [UIFont systemFontOfSize:15];
    [appearance setTitleTextAttributes:disAttrs forState:UIControlStateDisabled];
    
}

//页面跳转会调用这个方法
-(void)pushViewController:(UIViewController *)viewController animated:(BOOL)animated
{
    //self.viewControllers.count  控制器栈中控制器数量
    if (self.viewControllers.count > 0) {
        //隐藏标签栏
        viewController.hidesBottomBarWhenPushed = YES;
        // 全局设置导航栏按钮
        viewController.navigationItem.leftBarButtonItem = [UIBarButtonItem itemWithImageName:@"navigationbar_back" highImageName:@"navigationbar_back_highlighted" target:self action:@selector(back)];
        viewController.navigationItem.rightBarButtonItem = [UIBarButtonItem itemWithImageName:@"navigationbar_more" highImageName:@"navigationbar_more_highlighted" target:self action:@selector(more)];
  
    }
    [super pushViewController:viewController animated:animated];
}

 

导航控制器--NavgationController

标签:

原文地址:http://www.cnblogs.com/jsnan/p/4305502.html

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