BaseNavigationController自定义导航栏
#import <UIKit/UIKit.h>
@interface RCDNavigationViewController : UINavigationController<UIGestureRecognizerDelegate,UINavigationControllerDelegate>
@end
// .m
#import "RCDNavigationViewController.h"
@interface RCDNavigationViewController ()
@end
@implementation RCDNavigationViewController
- (void)viewDidLoad {
[super viewDidLoad];
__weak RCDNavigationViewController *weakSelf = self;
if ([self respondsToSelector:@selector(interactivePopGestureRecognizer)]) {
self.interactivePopGestureRecognizer.delegate = weakSelf;
self.delegate = weakSelf;
self.interactivePopGestureRecognizer.enabled = YES;
}
}
- (void)pushViewController:(UIViewController *)viewController
animated:(BOOL)animated {
if ([self respondsToSelector:@selector(interactivePopGestureRecognizer)] &&
animated == YES) {
self.interactivePopGestureRecognizer.enabled = NO;
}
[super pushViewController:viewController animated:animated];
}
- (NSArray *)popToRootViewControllerAnimated:(BOOL)animated {
if ([self respondsToSelector:@selector(interactivePopGestureRecognizer)] &&
animated == YES) {
self.interactivePopGestureRecognizer.enabled = NO;
}
return [super popToRootViewControllerAnimated:animated];
}
- (NSArray *)popToViewController:(UIViewController *)viewController
animated:(BOOL)animated {
if ([self respondsToSelector:@selector(interactivePopGestureRecognizer)]) {
self.interactivePopGestureRecognizer.enabled = NO;
}
return [super popToViewController:viewController animated:animated];
}
#pragma mark UINavigationControllerDelegate
- (void)navigationController:(UINavigationController *)navigationController
didShowViewController:(UIViewController *)viewController
animated:(BOOL)animate {
if ([self respondsToSelector:@selector(interactivePopGestureRecognizer)]) {
self.interactivePopGestureRecognizer.enabled = YES;
}
}
//UIGestureRecognizerDelegate
- (BOOL)gestureRecognizerShouldBegin:(UIGestureRecognizer *)gestureRecognizer {
if ([gestureRecognizer isEqual:self.interactivePopGestureRecognizer] &&
self.viewControllers.count > 1 &&
[self.visibleViewController isEqual:[self.viewControllers lastObject]]) {
//判断当导航堆栈中存在页面,并且 可见视图 如果不是导航堆栈中的最后一个视图时,就会屏蔽掉滑动返回的手势。此设置是为了避免页面滑动返回时因动画存在延迟所导致的卡死。
return YES;
} else {
return NO;
}
}
@end
BaseNavigationController自定义导航栏的更多相关文章
- 分别用ToolBar和自定义导航栏实现沉浸式状态栏
一.ToolBar 1.在build.gradle中添加依赖,例如: compile 'com.android.support:appcompat-v7:23.4.0' 2.去掉应用的ActionBa ...
- swift 自定义导航栏颜色
func setNavigationApperance(){ //自定义导航栏颜色 [self.navigationController?.navigationBar.barTintColor = U ...
- ios7以上自定义导航栏标题的字体大小及颜色的方法
自定义导航栏的字体和颜色,只需要自定义一个lable,然后将lable添加到导航栏的titleview中就可以了 代码如下 UILabel *label = [[UILabel alloc] init ...
- iOS 自定义导航栏笔记
一.UINavigationBar的结构 导航栏几乎是每个页面都会碰到的问题,一般两种处理方式:1.隐藏掉不显示 2.自定义 1. 添加导航栏 TestViewController * mainVC ...
- 微信小程序自定义导航栏
微信小程序需要自定义导航栏,特别是左上角的自定义设置,可以设置返回按钮,菜单按钮,配置如下: 1.在app.json的window属性中增加: navigationStyle:custom 顶部导航栏 ...
- iOS:自定义导航栏,随着tableView滚动显示和隐藏
自定义导航栏,随着tableView滚动显示和隐藏 一.介绍 自定义导航栏是APP中很常用的一个功能,通过自定义可以灵活的实现动画隐藏和显示效果.虽然处理系统的导航栏也可以实现,但是这个是有弊端的,因 ...
- 微信小程序 - 自定义导航栏(提示)
点击下载: 自定义导航栏示例
- 微信小程序——自定义导航栏
微信头部导航栏可能通过json配置: 但是有时候我们项目需求可能需要自定义头部导航栏,如下图所示: 现在具体说一下实现步骤及方法: 步骤: 1.在 app.json 里面把 "navigat ...
- 微信小程序-如何自定义导航栏(navigationStyle)?
小程序是越来越开放了,微信版本 6.6.0可以自定义导航? 先了解下app.json中window配置navigationStyle属性,即导航栏样式,仅支持 default/custom.custo ...
随机推荐
- 玩school 学习sql server 查询的网站
http://www.w3school.com.cn/sql/sql_like.asp
- centos7的xfs配置
XFS是扩展性高.高性能的文件系统.也是rhel7/centos7的默认文件系统.XFS支持metadata journaling,这使其能从crash中更快速的恢复.它也支持在挂载和活动的状态下进行 ...
- nginx 添加win 服务
https://jingyan.baidu.com/article/0964eca279aa818285f536a9.html
- import json
- C++ 面向对象: I/O对象的应用
1. 补充完整从text.txt文件读取数据后,再写入in.txt文件.2. 完成从text.txt文件读取数据后,进行排序,再写入in.txt文件.数据量自行设定.3. 请解决在主程序文件中加载多个 ...
- 基于IFC的大型三维城市群体——智慧城市模拟
- resize和reserve的区别
转自http://blog.csdn.net/jackywgw/article/details/6248342 首先必须弄清楚两个概念: 1.capacity 指容器在分配新的存储空间之前能存储的元素 ...
- ROS Learning-023 (提高篇-001) 准备工作 --- 安装一些必要的软件包
ROS 提高篇-001 - 准备工作 - 安装一些必要的软件 我使用的虚拟机软件:VMware Workstation 11 使用的Ubuntu系统:Ubuntu 14.04.4 LTS ROS 版本 ...
- QT中显示图像数据
博客转载自:https://blog.csdn.net/lg1259156776/article/details/52325091 一般图像数据都是以RGBRGBRGB……字节流的方式(解码完成后的原 ...
- Redis了解
1. 使用Redis有哪些好处? (1) 速度快,因为数据存在内存中,类似于HashMap,HashMap的优势就是查找和操作的时间复杂度都是O(1) (2) 支持丰富数据类型,支持string,li ...