通过appearance设置app主题

原文链接://www.greatytc.com/p/ede07db3017a

著作权归作者所有,转载请联系作者获得授权,并标注“简书作者”。

背景

最近在看开源中国的源代码,里面有一些自己不熟悉的知识,记录下来最为总结

参考资料

oschina源码

http://git.oschina.net/oschina/iphone-app

TintColor解析

http://blog.kingiol.com/blog/2014/01/09/ios7-day-by-day-day6-tint-color/

原文链接://www.greatytc.com/p/ede07db3017a

著作权归作者所有,转载请联系作者获得授权,并标注“简书作者”。

oschina源码分析

//再plist文件中设置View controller-based status bar appearance 为

NO才能起效[[UIApplicationsharedApplication]

setStatusBarStyle:UIStatusBarStyleLightContent];//导航条上标题的颜色

NSDictionary*navbarTitleTextAttributes =

@{NSForegroundColorAttributeName:[UIColorwhiteColor]};

[[UINavigationBarappearance]

setTitleTextAttributes:navbarTitleTextAttributes];//导航条上UIBarButtonItem颜

色[[UINavigationBarappearance]

setTintColor:[UIColorwhiteColor]];//TabBar选中图标的颜色,默认是蓝色

[[UITabBarappearance]

setTintColor:[UIColorcolorWithHex:0x15A230]];//TabBarItem选中的颜色

[[UITabBarItemappearance]

setTitleTextAttributes:@{NSForegroundColorAttributeName:[UIColorcolorWithHex:0x15A230]}

forState:UIControlStateSelected];//导航条的背景颜色[[UINavigationBarappearance]

setBarTintColor:[UIColornavigationbarColor]];//TabBar的背景颜色

[[UITabBarappearance] setBarTintColor:[UIColortitleBarColor]];

[UISearchBarappearance].tintColor=

[UIColorredColor];//当某个class被包含在另外一个class内时,才修改外观。

[[UITextFieldappearanceWhenContainedIn:[UISearchBarclass],nil]

setCornerRadius:14.0];

[[UITextFieldappearanceWhenContainedIn:[UISearchBarclass],nil]

setAlpha:0.6];UIPageControl*pageControl = [UIPageControlappearance];

pageControl.pageIndicatorTintColor= [UIColorcolorWithHex:0xDCDCDC];

pageControl.currentPageIndicatorTintColor= [UIColorgrayColor];

[[UITextFieldappearance] setTintColor:[UIColornameColor]];

[[UITextViewappearance]  setTintColor:[UIColornameColor]];

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • 背景 最近在看开源中国的源代码,里面有一些自己不熟悉的知识,记录下来最为总结 参考资料 oschina源码http...
    面试小集阅读 8,940评论 0 4
  • UIWindow 初始化: self.window= [[UIWindowalloc]initWithFrame:...
    Sunny_Fight阅读 4,668评论 0 1
  • 发现 关注 消息 iOS 第三方库、插件、知名博客总结 作者大灰狼的小绵羊哥哥关注 2017.06.26 09:4...
    肇东周阅读 14,270评论 4 61
  • 快2 你不可能把一首诗 拆成一本词典 一条抖动意义的条目鱼 你不可能把一把椅子 拆成一棵树 一件青山的青衫 你不可...
    我是蝎大人阅读 1,482评论 6 2
  • 一、奇迹 1、起床后为早餐发愁时,灵感告诉我牛排和水饺搭配完美,于是做了这样的早餐,儿子非常爱吃 2、带儿子出门聚...
    汪荣阅读 1,261评论 0 0