IOS 自定义全局navigaitonbar 属性样式

@implementation ZBMainViewController

 

- (void)viewDidLoad {

    [super viewDidLoad];

  

}

 

+(void)initialize

{

    [self setupBarButtonItemTheme];

 

    [self setupNavigationBarTheme];

}

 

+(void)setupBarButtonItemTheme{

 

    UIBarButtonItem *appearance=[UIBarButtonItem appearance];

    

    NSMutableDictionary *dict=[NSMutableDictionary dictionary];

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

   dict[NSForegroundColorAttributeName]=[UIColor greenColor];

    NSShadow *shadow=[[NSShadow alloc] init];

    shadow.shadowColor=[UIColor blueColor];

    shadow.shadowOffset=CGSizeMake(1, 1);

    

    

    dict[NSShadowAttributeName]=shadow;

    

    [appearance setTitleTextAttributes:dict forState:UIControlStateNormal];

}

 

+(void)setupNavigationBarTheme{

    

    

    UINavigationBar *apperarance=[UINavigationBar appearance];

    [apperarance setBackgroundImage:[UIImage imageNamed:@"bar_background"] forBarMetrics:UIBarMetricsDefault];

    

    NSMutableDictionary *dict=[NSMutableDictionary dictionary];

 

    dict[NSFontAttributeName]=[UIFont systemFontOfSize:18];

    dict[NSForegroundColorAttributeName]=[UIColor redColor];

   NSShadow *shadow= [[NSShadow alloc]init];

    shadow.shadowColor=[UIColor grayColor];

    shadow.shadowOffset=CGSizeMake(1, 1);

    

    dict[NSShadowAttributeName]=shadow;

    

    [apperarance setTitleTextAttributes:dict];

    

}

 

posted @ 2014-12-11 00:14  銱ル╬鎯噹  阅读(455)  评论(0编辑  收藏  举报