Skip to content

Instantly share code, notes, and snippets.

@HamGuy
Forked from robrasmussen/AppDelegate.swift
Created December 24, 2015 02:32
Show Gist options
  • Save HamGuy/e99c3f945be5b673b26d to your computer and use it in GitHub Desktop.
Save HamGuy/e99c3f945be5b673b26d 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment