导航栏上文字颜色的设置

#import "MyNavigationController.h"

@interface MyNavigationController ()

@end

@implementation MyNavigationController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
}

+(void)initialize
{
    // 1.获得bar对象
    UINavigationBar *navBar = [UINavigationBar appearance];
    

    // 2.1.设置bar背景
    
    // 设置导航栏背景图片
//    [navBar setBackgroundImage:[UIImage imageNamed:@"viewBg"] forBarMetrics:UIBarMetricsDefault];
    
    // 设置导航栏背景色
    [navBar setBarTintColor:[UIColor colorWithRed:39/255.0 green:39/255.0 blue:39/255.0 alpha:1.0]];

    // 设置导航栏左右bar button item的颜色
    [navBar setTintColor:[UIColor whiteColor]];
    
    // 设置导航栏中间标题的文字颜色
    [navBar setTitleTextAttributes:[NSDictionary dictionaryWithObjectsAndKeys:[UIColor whiteColor],NSForegroundColorAttributeName, nil]];
    
    // 要保持默认的透明传统效果,需要设置下面2个方法
    [navBar setTranslucent:YES];
    [navBar setShadowImage:[[UIImage alloc] init]];
    
    // 这个方法可以不写
    [navBar setBackgroundColor:[UIColor clearColor]];
    
}

@end

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值