废话不多说,直接上代码
UIButton *backBtn = [UIButton buttonWithType:UIButtonTypeCustom];
backBtn.frame = CGRectMake(0, 5, 27, 27);
[backBtn setImage:[UIImage imageNamed:@"返回.png"] forState:UIControlStateNormal];
[backBtn addTarget:self action:@selector(back) forControlEvents:UIControlEventTouchUpInside];//监听按钮
UIBarButtonItem *backItem = [[UIBarButtonItem alloc] initWithCustomView:backBtn];
self.navigationItem.leftBarButtonItem = backItem;//把自定义的返回按钮添加到导航栏左边
下面需要写一个返回按钮点击事件的方法
-(void)back{
[self.navigationController popViewControllerAnimated:YES];
}