The document discusses theming applications in iOS. It introduces UIAppearance, which allows setting the appearance of all instances of a class. Previously, each view controller had to manually set styles like tint color. With UIAppearance, a theme manager can set the style once on the UIAppearance proxy for a class, and all instances will take on that style. However, UIAppearance does not work for all UIView subclasses like UITableViewCell and UITextField. The document provides examples of using UIAppearance to theme navigation bars across an application.
Spring Boot vs Quarkus the ultimate battle - DevoxxUK
April iOS Meetup - UIAppearance Presentation
1. What's On For Today?
1.Theming Applications
2.Introducing UIAppearance
3.Example
2. How do you "theme" your
application with color, style?
3.
4. Common UI Customizations
– UINavigationBar tint color, title image
– UIToolbar tint color
– UIBarButtonItem tint color, style
– UIButton, UILabel, etc.
5. Pre-iOS5, How Did We Customize?
– viewWillAppear:
– Subclassing UIKit classes' drawRect:
method
– NSNotificationCenter
6. Pre-iOS5, How Did We Customize?
-(void)viewWillAppear:(BOOL)animated:
{
[super viewWillAppear:animated];
// What is our current theme?
NSUserDefaults *settings = [NSUserDefaults standardUserDefaults];
NSString *theme = [settings objectForKey:@"theme"];
// Set up color based on theme
if ([theme isEqualToString:@"red"]) {
self.navBar.tintColor = [UIColor redColor];
}
else {
self.navBar.tintColor = [UIColor blueColor];
}
}
7. The Problem With All Of This
• Every view controller needs to "know"
about how to handle themes/styles
• Lots of copy & pasted code, annoying
to maintain or add themes
Swinburne University of Technology
8. What's On For Today?
1. Theming Applications
2. Introducing UIAppearance
3. Example
13. More details…
• Unfortunately, Apple hasn't documented this
feature well yet.
• Unfortunately, not all UIView subclasses work
yet
• Search for UI_APPEARANCE_SELECTOR in
Spotlight
• Full reverse-engineered list here:
http://www.raywenderlich.com/4344/user-interface-customization-in-ios-5