设置控件全局显示样式appearance proxy
2013-09-22 10:05
323 查看
appearance是apple在iOS5.0上加的一个协议,它让程序员可以很轻松地改变某控件的全局样式(背景)
支持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
例如:
[[UINavigationBarappearance] setTintColor:[UIColorblackColor]];
[[UISearchBarappearance] setTintColor:[UIColorblackColor]];
注意:
初学者肯定会任意调用方法,大部分方法时无效的,如果调用时会抛出unknown selector 异常
那么如何查看你调用的方法时有效的呢,我们可以在此类的头文件中查看包含“UI_APPEARANCE_SELECTOR”常量的方法。
例如UIToolBar
它支持下列方法
@property(nonatomic,retain) UIColor *tintColor UI_APPEARANCE_SELECTOR;
- (void)setBackgroundImage:(UIImage *)backgroundImage forToolbarPosition:(UIToolbarPosition)topOrBottom barMetrics:(UIBarMetrics)barMetrics NS_AVAILABLE_IOS(5_0) UI_APPEARANCE_SELECTOR;
- (UIImage *)backgroundImageForToolbarPosition:(UIToolbarPosition)topOrBottom barMetrics:(UIBarMetrics)barMetrics NS_AVAILABLE_IOS(5_0) UI_APPEARANCE_SELECTOR;
- (void)setShadowImage:(UIImage *)shadowImage forToolbarPosition:(UIToolbarPosition)topOrBottom NS_AVAILABLE_IOS(6_0) UI_APPEARANCE_SELECTOR;
- (UIImage *)shadowImageForToolbarPosition:(UIToolbarPosition)topOrBottom NS_AVAILABLE_IOS(6_0) UI_APPEARANCE_SELECTOR;
了解更多请访问:http://developer.apple.com/library/ios/#documentation/uikit/reference/UIAppearance_Protocol/Reference/Reference.html。
@selector(appearance)
支持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
例如:
[[UINavigationBarappearance] setTintColor:[UIColorblackColor]];
[[UISearchBarappearance] setTintColor:[UIColorblackColor]];
注意:
初学者肯定会任意调用方法,大部分方法时无效的,如果调用时会抛出unknown selector 异常
那么如何查看你调用的方法时有效的呢,我们可以在此类的头文件中查看包含“UI_APPEARANCE_SELECTOR”常量的方法。
例如UIToolBar
它支持下列方法
@property(nonatomic,retain) UIColor *tintColor UI_APPEARANCE_SELECTOR;
- (void)setBackgroundImage:(UIImage *)backgroundImage forToolbarPosition:(UIToolbarPosition)topOrBottom barMetrics:(UIBarMetrics)barMetrics NS_AVAILABLE_IOS(5_0) UI_APPEARANCE_SELECTOR;
- (UIImage *)backgroundImageForToolbarPosition:(UIToolbarPosition)topOrBottom barMetrics:(UIBarMetrics)barMetrics NS_AVAILABLE_IOS(5_0) UI_APPEARANCE_SELECTOR;
- (void)setShadowImage:(UIImage *)shadowImage forToolbarPosition:(UIToolbarPosition)topOrBottom NS_AVAILABLE_IOS(6_0) UI_APPEARANCE_SELECTOR;
- (UIImage *)shadowImageForToolbarPosition:(UIToolbarPosition)topOrBottom NS_AVAILABLE_IOS(6_0) UI_APPEARANCE_SELECTOR;
了解更多请访问:http://developer.apple.com/library/ios/#documentation/uikit/reference/UIAppearance_Protocol/Reference/Reference.html。
相关文章推荐
- iOS 设置控件全局显示样式appearance proxy
- 设置控件全局显示样式appearance proxy
- 设置控件全局显示样式appearance proxy
- 设置控件全局显示样式 appearance
- [转]设置控件全局显示样式appearance proxy
- 设置控件全局显示样式appearance proxy
- 设置DevExpress GridControl控件时间列显示时、分、秒样式
- App中控件全局显示外观的设置 Appearance Proxies
- C# WinForm开发系列之DataTimePicker控件显示月份的限制和关于DataTimePicker和monthCalendar的样式设置问题
- WPF中ComboBox控件显示的样式设置
- ios之如何让图片显示成圆形的样式/设置控件边框大小以及颜色
- WPF设置全局控件样式
- 设置DevExpress GridControl控件时间列显示时、分、秒样式
- selector和shape结合设置控件样式
- android 中如何设置控件的字体和背景样式
- 【转】纯CSS设置Checkbox复选框控件的样式
- 隐藏和显示一个控件 设置按键不可用
- Android代码code设置9.png/9-patch 图片背景后,此view中的控件显示不正常
- jqery 实用工具 显示隐藏添加样式设置value值
- 继续聊WPF——设置网格控件列标题的样式