Set appearance of all instances of the class
suggest changeTo customize the appearance of all instances of a class, use the appearance proxy of that class. Set it before those instances are created. These Swift calls are Swift 2. For a navigation bar, set barTintColor. backgroundColor does not paint the bar.
Set UIButton tint color
Swift:
UIButton.appearance().tintColor = UIColor.greenColor()
Objective-C:
[UIButton appearance].tintColor = [UIColor greenColor];
Set UIButton background color
Swift:
UIButton.appearance().backgroundColor = UIColor.blueColor()
Objective-C:
[UIButton appearance].backgroundColor = [UIColor blueColor];
Set UILabel text color
Swift:
UILabel.appearance().textColor = UIColor.redColor()
Objective-C:
[UILabel appearance].textColor = [UIColor redColor];
Set UILabel background color
Swift:
UILabel.appearance().backgroundColor = UIColor.greenColor()
Objective-C:
[UILabel appearance].backgroundColor = [UIColor greenColor];
Set UINavigationBar tint color
Swift:
UINavigationBar.appearance().tintColor = UIColor.cyanColor()
Objective-C:
[UINavigationBar appearance].tintColor = [UIColor cyanColor];
Set UINavigationBar background color
Swift:
UINavigationBar.appearance().backgroundColor = UIColor.redColor()
Objective-C:
[UINavigationBar appearance].backgroundColor = [UIColor redColor];
Found a mistake? Have a question or improvement idea?
Let me know.
Table Of Contents