On iOS, The UINavigationController view can push many views without restrictions in the current view. However, some of the push buttons that come with them are not beautiful enough, and when the title of the previous page is very long, the return button is very long. How do I define a return button? Like the third image...
650) this. width = 650; "src =" http://img.blog.csdn.net/20130816204840687 "_ xhe_src =" http://img.blog.csdn.net/20130816204840687 "style =" max-width: 98%; "/> 650) this. width = 650; "src =" http://img.blog.csdn.net/20130816210121328 "_ xhe_src =" http://img.blog.csdn.net/20130816210121328 "style =" max-width: 98%; "/>
650) this. width = 650; "src =" http://img.blog.csdn.net/20130816204845000 "_ xhe_src =" http://img.blog.csdn.net/20130816204845000 "style =" max-width: 98%; "/>
Define an event in the view to be pushed
-(IBAction) pushVC :( id) sender {NavViewController * navVC = (NavViewController *) [self. storyboard instantiateViewControllerWithIdentifier: @ "NavViewController"]; navVC. title = NSLocalizedString (@ "set", nil); [self. navigationController pushViewController: navVC animated: YES];}
Replace the return button and define the Custom button
- (void)viewDidLoad{ [super viewDidLoad]; UIButton *backBtn = [UIButton buttonWithType:UIButtonTypeCustom]; backBtn.frame = CGRectMake(0, 0, 44, 44); [backBtn setImage:[UIImage imageNamed:@"back.png"] forState:UIControlStateNormal]; [backBtn addTarget:self action:@selector(doBack:) forControlEvents:UIControlEventTouchUpInside]; UIBarButtonItem *backItem = [[UIBarButtonItem alloc] initWithCustomView:backBtn]; self.navigationItem.leftBarButtonItem = backItem; // Do any additional setup after loading the view.}-(void)doBack:(id)sender{ [self.navigationController popViewControllerAnimated:YES];}
Source code: https://github.com/XFZLDXF/XFNavBarBtn
This article from the "fresh wind wave" blog, please be sure to keep this source http://duxinfeng.blog.51cto.com/3911492/1279119