自定导航控制器

//

//  CustNavigationViewController.m

//  生活荟

//

//  Created by 李冬强 on 15-1-19.

//  Copyright (c) 2015年 ldq. All rights reserved.

//



#import "CustNavigationViewController.h"



@interface CustNavigationViewController ()



@end



@implementation CustNavigationViewController



- (void)viewDidLoad {

    [super viewDidLoad];

    // Do any additional setup after loading the view.

}



// 第一次使用这个类调用

+ (void)initialize

{

    // 设置导航栏主题

    [self setupNavBarTheme];

    // 设置导航栏item主题

    [self setupBarButtonItemTheme];

    

}



// 设置导航栏主题

+ (void)setupNavBarTheme

{

    // 取出 appearance对象

    UINavigationBar *navBar = [UINavigationBar appearance];

    [[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleDefault];

    

    // 设置背景

//    navBar.barTintColor = ;

    

    // 设置标题属性

    NSMutableDictionary *textAttrs = [NSMutableDictionary dictionary];

    textAttrs[NSForegroundColorAttributeName] = kZhuTiColor;

    textAttrs[NSFontAttributeName] = [UIFont boldSystemFontOfSize:22];

    [navBar setTitleTextAttributes:textAttrs];

}



// 设置导航栏item主题

+ (void)setupBarButtonItemTheme

{

    UIBarButtonItem *item = [UIBarButtonItem appearance];

    // 设置背景

    

    // 设置文字属性

    NSMutableDictionary *textAttrs = [NSMutableDictionary dictionary];

    textAttrs[NSForegroundColorAttributeName] = [UIColor whiteColor];

    textAttrs[NSFontAttributeName] = [UIFont systemFontOfSize: 15];

    [item setTitleTextAttributes:textAttrs forState:UIControlStateNormal];

    [item setTitleTextAttributes:textAttrs forState:UIControlStateHighlighted];

    NSMutableDictionary *disableTextAttrs = [NSMutableDictionary dictionary];

    disableTextAttrs[NSFontAttributeName] = [UIColor lightGrayColor];

    [item setTitleTextAttributes:disableTextAttrs forState:UIControlStateDisabled];

}



- (void)pushViewController:(UIViewController *)viewController animated:(BOOL)animated

{

    if (self.viewControllers.count > 0) {

        viewController.hidesBottomBarWhenPushed = YES;

    }

    [super pushViewController:viewController animated:animated];

}





- (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

 

你可能感兴趣的:(控制器)