Skip to content

Instantly share code, notes, and snippets.

@michaelochs
Created September 20, 2013 08:56
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save michaelochs/6634925 to your computer and use it in GitHub Desktop.
Save michaelochs/6634925 to your computer and use it in GitHub Desktop.
Adds -[UINavigationBar setBarTintColor:] and -[UINavigationBar barTintColor] on iOS6 so that you don't have to check for that all the time.
#import <objc/runtime.h>
@implementation UINavigationBar (iOS7Tint)
static void setter(UINavigationBar *self, SEL _cmd, UIColor *tintColor)
{
self.tintColor = tintColor;
}
static UIColor *getter(UINavigationBar *self, SEL _cmd)
{
return self.tintColor;
}
+ (void)initialize
{
if (![self instancesRespondToSelector:@selector(setBarTintColor:)]) {
class_addMethod([self class], @selector(setBarTintColor:), (IMP)setter, "v@:@");
class_addMethod([self class], @selector(barTintColor), (IMP)getter, "@@:");
}
}
@end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment