iOS导航栏的一些小技巧

2018-07-17  本文已影响147人  DevinZ

一 隐藏系统导航栏

(void)viewWillAppear:(BOOL)animated {
    [super viewWillAppear:animated];
    self.navigationController.delegate = self;
}
// 将要显示控制器
- (void)navigationController:(UINavigationController *)navigationController willShowViewController:(UIViewController *)viewController animated:(BOOL)animated {
    // 判断要显示的控制器是否是自己
    BOOL target = [viewController isKindOfClass:[self class]];
    [self.navigationController target animated:YES];
}

二 添加系统右滑返回手势

 self.navigationController.interactivePopGestureRecognizer.delegate = self;

三 单独禁止某个页面系统的滑动返回功能

id traget = self.navigationController.interactivePopGestureRecognizer.delegate;
 UIPanGestureRecognizer * pan = [[UIPanGestureRecognizer alloc]initWithTarget:traget action:nil];
 [self.view addGestureRecognizer:pan];
上一篇 下一篇

猜你喜欢

热点阅读