通过appearance设置app主题

原文链接:http://www.jianshu.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/

原文链接:http://www.jianshu.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]];

你可能感兴趣的:(通过appearance设置app主题)