- 相關推薦
關于iOS中UIAppearance的使用
iOS5及其以后提供了一個比較強大的工具UIAppearance,我們通過UIAppearance設置一些UI的全局效果,這樣就可以很方便的實現UI的自定義效果又能最簡單的實現統一界面風格,它提供如下兩個方法。
+ (id)appearance
這個方法是統一全部改,比如你設置UINavBar的tintColor,你可以這樣寫:[[UINavigationBar appearance] setTintColor:myColor];
+ (id)appearanceWhenContainedIn:(Class <>)ContainerClass,...
這個方法可設置某個類的改變:例如:設置UIBarButtonItem 在UINavigationBar、UIPopoverController、UITabbar中的效果。就可以這樣寫
[[UIBarButtonItem appearanceWhenContainedIn:[UINavigationBar class], [UIPopoverController class],[UITabbar class] nil] setTintColor:myPopoverNavBarColor];
請注意*使用appearance設置UI效果最好采用全局的設置,在所有界面初始化前開始設置,否則可能失效。
支持UIAppearance協議的類可以訪問appearance selector ,它為receiver返回appearance proxy,我么可以給proxy發一些消息,諸如setTintColor:等
但是它并不是支持所有的UI類。下面列出它支持的類
1.UIActivitiIndicatorView
2.UIBarButtonItem
3.UIBarItem
4.UINavgationBar
5.UIPopoverControll
6.UIProgressView
7.UISearchBar
8.UISegmentControll
9.UISlider
10.UISwitch
11.UITabBar
12.UITabBarItem
13.UIToolBar
14.UIView
15.UIViewController
【iOS中UIAppearance的使用】相關文章:
IOS7新功能Airdrop使用教程03-22
iOS7.0.6如何正確維護和使用電池04-12
ios7八門神器怎么使用06-04
ios7.1.2怎么升級ios803-18
ios7降低到ios6的方法03-18
ios7如何降級到ios604-28
蘋果系統iOS11恢復iOS10教程03-18
松木在家具中的使用04-30
那些設備支持iOS11 iOS11好用嗎03-17
iOS7.1與iOS7.0.4區別明顯嗎03-18