加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

Swift中的外观代理/ UI_APPEARANCE_SELECTOR?

发布时间:2020-12-14 06:04:23 所属栏目:百科 来源:网络整理
导读:苹果文档说明: To participate in the appearance proxy API,tag your appearance property selectors in your header with UI_APPEARANCE_SELECTOR. 在Objective-C中,可以使用UI_APPEARANCE_SELECTOR注释属性,如下所示: @property (nonatomic,strong) U
苹果文档说明:

To participate in the appearance proxy API,tag your appearance
property selectors in your header with UI_APPEARANCE_SELECTOR.

在Objective-C中,可以使用UI_APPEARANCE_SELECTOR注释属性,如下所示:

@property (nonatomic,strong) UIColor *foregroundColor UI_APPEARANCE_SELECTOR;

我怎么能在Swift中做同样的事情?

将自定义视图属性标记为动态。

例如:

class YourCustomView: UIView {
    dynamic var subviewColor: UIColor? {
        get { return self.yourSubview.backgroundColor }
        set { self.yourSubview.backgroundColor = newValue }
    }
    ...
}

然后:

YourCustomView.appearance().subviewColor = UIColor.greenColor()

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读