iOS 设置导航栏的主题

来源:互联网 发布:sqlserver 注释快捷键 编辑:程序博客网 时间:2024/06/05 00:48

在导航控制器里

+ (void)initialize{    //设置导航栏主题(背景图片和文字属性)    UINavigationBar *navBar = [UINavigationBar appearance];    //设置背景图片    NSString *bgName = nil;    if ([[UIDevice currentDevice].systemVersion doubleValue] >= 7.0) {        bgName = @"NavBar64";    }else{        bgName = @"NavBar";    }    [navBar setBackgroundImage:[UIImage imageNamed:bgName] forBarMetrics:UIBarMetricsDefault];    //设置标题文字属性    NSMutableDictionary *attrs = [NSMutableDictionary dictionary];    attrs[NSForegroundColorAttributeName] = [UIColor whiteColor];    attrs[NSFontAttributeName] = [UIFont systemFontOfSize:16];    [navBar setTitleTextAttributes:attrs];}


0 0
原创粉丝点击