此方法可以自定义返回按钮,且不影响返回手势。
新方法:
self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc]
initWithImage:img
style:UIBarButtonItemStylePlain
target:self
action:@selector(onBack:)];
self.navigationController.interactivePopGestureRecognizer.delegate = (id<UIGestureRecognizerDelegate>)self;
老方法:
UIBarButtonItem *backButton = [[UIBarButtonItem alloc] initWithTitle:@"" style:UIBarButtonItemStylePlain target:self action:nil];
self.navigationController.navigationBar.topItem.backBarButtonItem = backButton;
本文介绍了一种在iOS应用中自定义导航栏返回按钮的方法,并保持了原生返回手势的功能。通过创建UIBarButtonItem实例并设置其样式、图片及响应动作,实现定制化的返回按钮效果。
2275





