iOS 设置导航条的主题
来源:互联网 发布:工程网络计划图 编辑:程序博客网 时间:2024/05/16 03:44
/** * 系统在第一次使用这个类的时候调用(1个类只会调用一次) */+ (void)initialize{ // 设置导航栏主题 UINavigationBar *navBar = [UINavigationBar appearance]; // 设置背景图片 NSString *bgName = nil; if (iOS7) { // 至少是iOS 7.0 bgName = @"NavBar64"; } else { // 非iOS7 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]; //设置BarButtonItem的主题 UIBarButtonItem *item=[UIBarButtonItem appearance]; //设置文字颜色 NSMutableDictionary *itemAttrs=[NSMutableDictionary dictionary]; itemAttrs[NSFontAttributeName]=[UIFont systemFontOfSize:14]; itemAttrs[NSForegroundColorAttributeName]=[UIColor whiteColor]; [item setTitleTextAttributes:itemAttrs forState:UIControlStateNormal]; if (!iOS7) { //设置按钮背景 [item setBackgroundImage:[UIImage imageNamed:@"NavButton"] forState:UIControlStateNormal barMetrics:UIBarMetricsDefault]; [item setBackgroundImage:[UIImage imageNamed:@"NavButtonPressed"] forState:UIControlStateHighlighted barMetrics:UIBarMetricsDefault]; //设置返回按钮的背景 [item setBackButtonBackgroundImage:[UIImage imageNamed:@"NavButton"] forState:UIControlStateNormal barMetrics:UIBarMetricsDefault]; [item setBackButtonBackgroundImage:[UIImage imageNamed:@"NavButtonPressed"] forState:UIControlStateHighlighted barMetrics:UIBarMetricsDefault]; } else{ navBar.tintColor=[UIColor whiteColor]; } }
0 0
- iOS 设置导航条的主题
- iOS 设置导航栏的主题
- iOS navigationcontroller 的导航条的设置
- ios导航条的设置(UINavigati…
- iOS 开发导航条的透明设置
- iOS---导航条的一些设置
- IOS 导航条的样式设置
- ios设置导航条背景图片
- iOS---设置导航条文字
- ios设置导航条透明的两句代码
- 导航条的颜色设置
- iOS导航条设置为白色
- iOS 设置NavgationBar导航条为透明
- iOS开发navigationBar导航条和navigationItem设置:基本搞定导航条上的文字和按钮以及各种跳转
- iOS 导航条透明(以及自定义颜色)的方法,去掉导航条底部黑线,随着tableView滚动设置导航条变色
- iOS 之设置导航条文字的颜色和设置字体的大小
- ios-新浪微博(5)设置导航栏主题
- iOS 导航控制器、导航条、导航项、控制器的关系
- 删除mac上的插件教程
- Service和activty交互方式
- Java中的静态绑定和动态绑定
- Android最佳性能实践(一)——合理管理内存
- coeforces 628C. Bear and String Distance
- iOS 设置导航条的主题
- jasoncpp在visual studio下的编译和使用
- Android Interface Definition Language (AIDL)
- 【Bugly干货分享】iOS内存管理:从MRC到ARC实践
- Servlet过滤器和监听器知识总结
- Android优化Adapter内的Click、LongClick
- MySQL常用命令
- Retrofit 2.0 + OkHttp 3.0 配置
- 第一章 引言