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:
Then:
In Swift, you don't need (actually, you cannot) to annotate properties with
UI_APPEARANCE_SELECTOR
.Just make sure your appearance property accessor methods be of the form:
For example:
Then you can set your appearance property like this:
I currently using this solution in my Swift project and it works, hope it's helpful to you too.
I did not find the solution but a workaround. Instead of annotating the properties I made them as a class variable.
And in the file where I setup all my appearances:
I hope it will help somebody!