SMTNavigationBar 简单地将自定义导航栏集中管理。创建一次导航按钮,然后就可以在任意 UIViewControllers 中访问它。
#import "UIViewController+SMTNavigationBar.h"
UIButton * leftBtn = [[UIButton alloc]initWithFrame:CGRectMake(0, 0, 44, 44)];
[leftBtn setTitle:@"left" forState:UIControlStateNormal];
[leftBtn setTitleColor:[UIColor redColor] forState:UIControlStateNormal];
[self createButtonWithKey:@"leftBtn" button:leftBtn];
[self setLeftBarButtonItemWithKey:@"leftBtn" isDefault:YES isPop:YES];
-(void)viewWillAppear:(BOOL)animated{
[self loadDefaults];
}
/* List of items
LEFT_ITEM
RIGHT_ITEM
TITLE_ITEM
TITLEVIEW_ITEM
*/
[self loadDefaultWithItem:RIGHT_ITEM];
[self setLeftBarButtonItemWithKey:@"leftBtn" isDefault:YES withSelectorBlock:^(UIViewController *vc) {
//When controller is popped. VC becomes a uinavigationcontroller class.
if([vc isKindOfClass:[UINavigationController class]]){
UINavigationController * vcs = (UINavigationController *) vc;
vc = [vcs viewControllers].lastObject;
}
NSLog(@"This is the block method generated on first VC but is now being presented in %@",vc.navigationItem.title);
}];
if([vc isKindOfClass:[UINavigationController class]]){
UINavigationController * vcs = (UINavigationController *) vc;
vc = [vcs viewControllers].lastObject;
}
[self runLeftSuperBlock];
[self runRightSuperBlock];
-(void)SMTNavigationBarDidTapLeftItem
-(void)SMTNavigationBarDidTapRightItem
-(void)SMTNavigationBarDidPop
UIImageView * imgView =[[UIImageView alloc] initWithImage:[UIImage imageNamed:@"logo.png"]];
imgView.contentMode = UIViewContentModeScaleAspectFill;
imgView.clipsToBounds = NO;
[self createTitleViewWithKey:@"titleView" titleview:imgView];
[self setTitleViewWithKey:@"titleView" isDefault:YES];
[self setTitle:@"ABC" isDefault:YES];
1.2
v.1.2
v.1.0
riza027 - https://github.com/riza027/
分叉,实现,发起Pull Request。
版权所有 (c) 2015 Steffi Tan
有关详细信息,请参阅MIT-LICENSE。