The Apple documentation states:
To participate in the appearance proxy API, tag your appearance property selectors in your header with UI_APPEARANCE_SELECTOR.
In Objective-C one can annotate properties with UI_APPEARANCE_SELECTOR
like this:
@property (nonatomic, strong) UIColor *foregroundColor UI_APPEARANCE_SELECTOR;
How can I do the same in Swift?
Mark your custom view property as dynamic
.
For example:
class YourCustomView: UIView { @objc dynamic var subviewColor: UIColor? { get { return self.yourSubview.backgroundColor } set { self.yourSubview.backgroundColor = newValue } } ... }
Then:
YourCustomView.appearance().subviewColor = UIColor.greenColor()
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With