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 ...
随机推荐
- CSS3图片以中心缩放,放大超出隐藏实现
首页,重点是有一个包裹img标签的容器,这里我们给该容器设置一个class为selfScale <div class="selfScale"> <img sr=& ...
- myeclipse与eclipse的web项目部署区别
一.myeclipse之web项目的部署(发布)流程 web项目的部署(发布)流程2008-01-18 14:35 在myeclipse下新建web工程abc.系统设置默认如下: 项目保存位置:wor ...
- Tiny4412 Android 启动流程
Android系统的启动主要包括三个阶段: ①BootLoader启动 ②Linux Kernel启动 ③Android系统启动 前面我们大致分析了前面两个步骤,即u-boot和内核的启动流程(内核启 ...
- DAY11-MYSQL单表查询
一 单表查询的语法 SELECT 字段1,字段2... FROM 表名 WHERE 条件 GROUP BY field HAVING 筛选 ORDER BY field LIMIT 限制条数 二 关键 ...
- 什么是Scatter/Gather?
scatter/gather指的在多个缓冲区上实现一个简单的I/O操作,比如从通道中读取数据到多个缓冲区,或从多个缓冲区中写入数据到通道: scatter(分散):指的是从通道中读取数据分散到多个缓冲 ...
- Android 自定义格式的对话框
aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAAAaoAAADvCAIAAAAsDwfKAAAgAElEQVR4nLy9bZhcVZUofEg0GcURBk ...
- NLP整体流程的代码
import nltk import numpy as np import re from nltk.corpus import stopwords # 1 分词1 text = "Sent ...
- c#日期与字符串间的转换(转)
1.日期转字符串(转载) 在编程中经常要用到将日期变量转换为字符串的情况,而且不同的时候希望转换成不同格式的字符串 下面是一些常用的转换及转换结果: (查看格式说明) 以日期为例: 2009-09-0 ...
- win10 更换秘钥报错:拒绝访问:所请求的操作需要提升特权
直接打开cmd执行换秘钥的命令: slmgr /ipk VK7JG-NPHTM-C97JM-9MPGT-3V66T slmgr /skms kms.xspace.in slmgr /ato 报错如图: ...
- IB使用
A:给控件添加方法或变量. 1.窗口上拖个控件 NSButton 2..点右上那张狗脸(Editor)对上的. 3.右键控件.拖到头文件中. 4 .选择加响应方法或变量.