Skip to content

Instantly share code, notes, and snippets.

@robrasmussen
Last active December 24, 2015 02:32
Show Gist options
  • Save robrasmussen/5c8ea05e715764879a8e to your computer and use it in GitHub Desktop.
Save robrasmussen/5c8ea05e715764879a8e to your computer and use it in GitHub Desktop.
Example for how to set up a UIAppearance proxy specific to one controller in Swift
import UIKit
@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {
var window: UIWindow?
func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
UIButton.appearanceProxyIn(ViewController).backgroundColor = UIColor.redColor()
UIButton.appearanceProxyIn(ViewController).tintColor = UIColor.yellowColor()
UIButton.appearance().tintColor = UIColor.blackColor()
return true
}
}
#import <UIKit/UIKit.h>
@interface UIView(Appearance)
+(instancetype)appearanceProxyIn:(Class)klass;
@end
#import "UIView+Appearance.h"
@implementation UIView(Appearance)
+(instancetype)appearanceProxyIn:(Class)klass {
return [self appearanceWhenContainedIn:klass, nil];
}
@end
@robrasmussen
Copy link
Author

This gets you what you asked for, could make it work for an array of view controllers if you need it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment