统一设置导航栏的皮肤颜色

+ (void)initialize{

    

    UINavigationBar *bar = [UINavigationBar appearance];

//    [self buttonImageFromColor:[UIColor blackColor]]

    UIImage *image = [UIImage imageNamed:@"img_nav_topbar"];

    [bar setBackgroundImage:image forBarMetrics:UIBarMetricsDefault];

    

    // 设置uibarbuttonitem统一为白色

    UIBarButtonItem *item = [UIBarButtonItem appearance];

    NSMutableDictionary *attributes = [NSMutableDictionary dictionary];

    attributes[NSForegroundColorAttributeName] = [UIColor whiteColor];

    [item setTitleTextAttributes:attributes forState:UIControlStateNormal];

    

    // 设置导航栏返回按钮的颜色

    [bar setTintColor:[UIColor whiteColor]];

    

    // 导航栏设置黑色后,标题设置白色

    NSMutableDictionary *dic = [NSMutableDictionary dictionary];

    dic[NSForegroundColorAttributeName] = [UIColor whiteColor];

    [bar setTitleTextAttributes:dic];

}

 

posted @ 2015-04-25 20:03  _boy  阅读(412)  评论(0编辑  收藏  举报