Last active
December 24, 2015 02:32
-
-
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#import <UIKit/UIKit.h> | |
@interface UIView(Appearance) | |
+(instancetype)appearanceProxyIn:(Class)klass; | |
@end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#import "UIView+Appearance.h" | |
@implementation UIView(Appearance) | |
+(instancetype)appearanceProxyIn:(Class)klass { | |
return [self appearanceWhenContainedIn:klass, nil]; | |
} | |
@end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This gets you what you asked for, could make it work for an array of view controllers if you need it.