April iOS Meetup - UIAppearance Presentation

1,945 views

Published on

Published in: Technology
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
1,945
On SlideShare
0
From Embeds
0
Number of Embeds
7
Actions
Shares
0
Downloads
5
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

April iOS Meetup - UIAppearance Presentation

  1. 1. Whats On For Today?1.Theming Applications2.Introducing UIAppearance3.Example
  2. 2. How do you "theme" yourapplication with color, style?
  3. 3. Common UI Customizations– UINavigationBar tint color, title image– UIToolbar tint color– UIBarButtonItem tint color, style– UIButton, UILabel, etc.
  4. 4. Pre-iOS5, How Did We Customize?– viewWillAppear:– Subclassing UIKit classes drawRect: method– NSNotificationCenter
  5. 5. 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]; }}
  6. 6. 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
  7. 7. Whats On For Today?1. Theming Applications2. Introducing UIAppearance3. Example
  8. 8. Without UIAppearance setTintColor: UIViewController UINavigationBar setTintColor: UIViewController UINavigationBar setTintColor: UIViewController UINavigationBar
  9. 9. With UIAppearance, 1 ThemeManager setTintColor: setTintColor: UINavigationBar UIAppearance Proxy UINavigationBar UINavigationBar
  10. 10. With UIAppearance, 2 UIViewController alloc/init -tintColor: UINavigationBar UIAppearance Proxy
  11. 11. Current UIAppearance classes– UIActivityIndicatorView– UIBarButtonItem– UIBarItem– UINavigationBar– UIProgressView– UISearchBar– UISegmentedControl– UISlider– UISwitch– UITabBar– UITabBarItem– UIToolbarSource: http://stackoverflow.com/questions/9424112/what-properties-can-i-set-via-an-uiappearance-proxy
  12. 12. More details…• Unfortunately, Apple hasnt 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
  13. 13. Who is missing?• UITableViewCell• UITextField• UILabel
  14. 14. Whats On For Today?1.Theming Applications2.Introducing UIAppearance3.Example
  15. 15. THANK YOUQuestions?

×