iOS UIAppearance Appearance for class when contained in container class

Help us to keep this website almost Ad Free! It takes only 10 seconds of your time:
> Step 1: Go view our video on YouTube: EF Core Bulk Extensions
> Step 2: And Like the video. BONUS: You can also share it!

Example

Use appearanceWhenContainedInInstancesOfClasses: to customize the appearance for instance of a class when contained within an instance of container class. For example customization of UILabel's textColor and backgroundColor within ViewController class will look like this:

Set UILabel text color

Swift:

UILabel.appearanceWhenContainedInInstancesOfClasses([ViewController.self]).textColor = UIColor.whiteColor()

Objective-C:

[UILabel appearanceWhenContainedInInstancesOfClasses:@[[ViewController class]]].textColor = [UIColor whiteColor];

Set UILabel background color

Swift:

UILabel.appearanceWhenContainedInInstancesOfClasses([ViewController.self]).backgroundColor = UIColor.blueColor()

Objective-C:

[UILabel appearanceWhenContainedInInstancesOfClasses:@[[ViewController class]]].backgroundColor = [UIColor blueColor];


Got any iOS Question?