Appearance proxies / UI_APPEARANCE_SELECTOR in Swift?

后端 未结 4 2080
庸人自扰
庸人自扰 2020-12-25 10:06

The Apple documentation states:

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

4条回答
  •  天涯浪人
    2020-12-25 10:42

    I did not find the solution but a workaround. Instead of annotating the properties I made them as a class variable.

    private struct StarFillColor { static var _color = UIColor.blackColor() }
    internal class var starFillColor: UIColor {
        get { return StarFillColor._color }
        set { StarFillColor._color = newValue }
    }
    

    And in the file where I setup all my appearances:

    MyClass.starFillColor = UIColor.r(181, g: 60, b: 109) 
    

    I hope it will help somebody!

提交回复
热议问题