Skip to content

Instantly share code, notes, and snippets.

@JigarM
Created January 30, 2015 10:20
Show Gist options
  • Save JigarM/200317cd9a36292eb0a4 to your computer and use it in GitHub Desktop.
Save JigarM/200317cd9a36292eb0a4 to your computer and use it in GitHub Desktop.
Empty navigation back button iOS7
//
// UINavigationItem+ArrowBackButton.h
// BellyCard
//
// Created by Mobmaxime on 30/01/15.
// Copyright (c) 2015 Mobmaxime. All rights reserved.
//
//
// UINavigationItem+ArrowBackButton.h
//
#import <UIKit/UIKit.h>
@interface UINavigationItem (ArrowBackButton)
@end
//
// UINavigationItem+ArrowBackButton.m
// BellyCard
//
// Created by Mobmaxime on 30/01/15.
// Copyright (c) 2015 Mobmaxime. All rights reserved.
//
#import "UINavigationItem+ArrowBackButton.h"
#import <objc/runtime.h>
@implementation UINavigationItem (ArrowBackButton)
static char kArrowBackButtonKey;
+ (void)load {
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
Method m1 = class_getInstanceMethod(self, @selector(backBarButtonItem));
Method m2 = class_getInstanceMethod(self, @selector(arrowBackButton_backBarButtonItem));
method_exchangeImplementations(m1, m2);
});
}
- (UIBarButtonItem *)arrowBackButton_backBarButtonItem {
UIBarButtonItem *item = [self arrowBackButton_backBarButtonItem];
if (item) {
return item;
}
item = objc_getAssociatedObject(self, &kArrowBackButtonKey);
if (!item) {
item = [[UIBarButtonItem alloc] initWithTitle:@"" style:UIBarButtonItemStyleBordered target:nil action:NULL];
objc_setAssociatedObject(self, &kArrowBackButtonKey, item, OBJC_ASSOCIATION_RETAIN_NONATOMIC);
}
return item;
}
@end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment