Custem NavigationBar LeftItem
@interface NUNavigationController ()
@property(nonatomic, strong) FRDLivelyButton *backBtn;
@end
@implementation KGNavigationController
- (void)pushViewController:(UIViewController *)viewController
animated:(BOOL)animated {
[self.backBtn setStyle:kFRDLivelyButtonStyleCaretLeft animated:YES];
[super pushViewController:viewController animated:animated];
if (viewController.navigationItem.leftBarButtonItem == nil &&
[self.viewControllers count] > 1) {
viewController.navigationItem.leftBarButtonItems = [self custemBackItem];
}
}
- (NSArray *)custemBackItem {
UIBarButtonItem *btnLeft =
[[UIBarButtonItem alloc] initWithCustomView:self.backBtn];
UIBarButtonItem *negativeSpacer = [[UIBarButtonItem alloc]
initWithBarButtonSystemItem:UIBarButtonSystemItemFixedSpace
target:nil
action:nil];
// if pre iOS 7, set width to 0
negativeSpacer.width = -15;
return @[ negativeSpacer, btnLeft ];
}
- (FRDLivelyButton *)backBtn {
if (!_backBtn) {
_backBtn = [[FRDLivelyButton alloc] initWithFrame:CGRectMake(0, 0, 36, 58)];
[_backBtn setStyle:kFRDLivelyButtonStyleCaretLeft animated:YES];
[_backBtn setOptions:@{
kFRDLivelyButtonLineWidth : @(1.5f),
kFRDLivelyButtonColor : [UIColor colorWithWhite:0.282 alpha:1.000]
}];
_backBtn.rac_command =
[[RACCommand alloc] initWithSignalBlock:^RACSignal * (id input) {
[self.view endEditing:YES];
[input setStyle:kFRDLivelyButtonStyleCaretRight animated:YES];
[self popViewControllerAnimated:YES];
return [RACSignal empty];
}];
}
return _backBtn;
}