|
使用[self.navigationController setNavigationBarHidden:NO animated:YES] 侧滑手势会被禁,所以需要加代理开启手势 - (void)viewDidLoad { [super viewDidLoad]; //设置代理 if ([self.navigationController respondsToSelector:@selector(interactivePopGestureRecognizer)]) { self.navigationController.interactivePopGestureRecognizer.delegate = self; } } - (void)viewWillAppear:(BOOL)animated { [super viewWillAppear:animated]; //会导致侧滑手势被禁 [self.navigationController setNavigationBarHidden:YES animated:animated]; } - (void)viewWillDisappear:(BOOL)animated { [super viewWillDisappear:animated]; //如果该控制器没有上级控制器,建议将使用[self.navigationController setNavigationBarHidden:NO animated:animated] 效果会更好点 [self.navigationController setNavigationBarHidden:NO animated:NO]; } #pragma mark - UIGestureRecognizerDelegate - (BOOL)gestureRecognizerShouldBegin:(UIGestureRecognizer *)gestureRecognizer { return YES; }
2、导航栏渐变介绍两个方法: //隐藏导航栏,但不隐藏上面的Item [self.navigationController.navigationBar setBackgroundImage:[[UIImage alloc] init] forBarMetrics:UIBarMetricsDefault]; //隐藏导航栏底部那条线 [self.navigationController.navigationBar setShadowImage:[[UIImage alloc] init]];
这个不做演示,推荐一个三方 LTNavigationBar 三、自定义TitleView直接上代码 UIView *titleView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 100, 40)]; UISwitch *switchView = [[UISwitch alloc] initWithFrame:CGRectMake(0, 0, 40, 40)]; switchView.center = titleView.center; [titleView addSubview:switchView]; self.navigationItem.titleView = titleView;
自定义TitleView (编辑:无忧刷机网 - 51刷机网)
【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!
|