自定义navigationbar左边的按钮
先放这里,以后复制就好~
viewdidload:
viewdidload:
self.navigationItem.leftBarButtonItem = [self leftBarButtonItem];
其它函数:
- (UIBarButtonItem *)leftBarButtonItem{
UIButton *left = [[UIButton alloc]initWithFrame:CGRectMake(0, 0, 11, 20)];
[left setBackgroundImage:[UIImage imageNamed:@"nav_back"] forState:UIControlStateNormal];
[left addTarget:self action:@selector(popViewCon) forControlEvents:UIControlEventTouchUpInside];
[left setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
[left setTitleColor:[UIColor blueColor] forState:UIControlStateHighlighted];
UIBarButtonItem *item = [self barItemWithCustomView:left];
return item;
}
- (UIBarButtonItem *)barItemWithCustomView:(id)custom{
return [[UIBarButtonItem alloc]initWithCustomView:(UIView *)custom];
}
-(void)popViewCon
{
[self.navigationController popViewControllerAnimated:YES];
}
评论
发表评论