UIAppearance Protocol Reference

ios5增加的两个统一定制控件样式的函数,具有全局的效果,一劳永逸。用法很简单,文档如下:

UIAppearance Protocol Reference

Conforms to
Framework
/System/Library/Frameworks/ UIKit.framework
Availability
Available in iOS 5.0 and later.
Declared in
UIAppearance.h

Overview

You use the UIAppearance protocol to get the appearance proxy for a class. You customize the appearance of instances of a class by sending appearance modification messages to the class’s appearance proxy.

There are two ways to customize appearance for objects: for all instances, and for instances contained within an instance of a container class.

//To customize the appearance of all instances of a class, you use appearance to get the appearance proxy for the class. For example, to modify the tint color for all instances ofUINavigationBar:

[[UINavigationBar appearance] setTintColor:myColor];


//To customize the appearances for instances of a class when contained within an instance of a container class, or instances in a hierarchy, you useappearanceWhenContainedIn: to get the appearance proxy for the class:

[[UIBarButtonItem appearanceWhenContainedIn:[UINavigationBar class], nil]
       setTintColor:myNavBarColor];

[[UIBarButtonItem appearanceWhenContainedIn:[UINavigationBar class], [UIPopoverController class], nil]
        setTintColor:myPopoverNavBarColor];

[[UIBarButtonItem appearanceWhenContainedIn:[UIToolbar class], nil]
        setTintColor:myToolbarColor];

[[UIBarButtonItem appearanceWhenContainedIn:[UIToolbar class], [UIPopoverController class], nil]
        setTintColor:myPopoverToolbarColor];

In any given view hierarchy, the outermost appearance proxy wins. Specificity (depth of the chain) is the tie-breaker. In other words, the containment statement inappearanceWhenContainedIn: is treated as a partial ordering. Given a concrete ordering (actual subview hierarchy), UIKit selects the partial ordering that is the first unique match when reading the actual hierarchy from the window down.

To support appearance customization, a class must conform to the UIAppearanceContainer protocol and relevant accessor methods must be marked with UI_APPEARANCE_SELECTOR.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值