上拉、下拉UITableView,交互式 模态弹出(自定义弹出动画)
部分代码 InteractiveTransition 类继承NSObject:
- (instancetype)initWithPresentingController:(UITableViewController *)presentingVc presentedController:(UIViewController *)presentedVc {
self = [super init];
if (self) {
self.vc = presentedVc;
self.vc.transitioningDelegate =self;
self.presentingVc = presentingVc;
}
return self;
} - (void)new_scrollViewWillBeginDragging:(UIScrollView *)scrollView {
self.interactiveTransition = [[UIPercentDrivenInteractiveTransition alloc]init];
[self.presentingVc presentViewController:self.vc animated:YES completion:nil];
} - (void)new_scrollViewDidScroll:(UIScrollView *)scrollView { CGFloat offsetY = fabs(scrollView.contentOffset.y); CGFloat screenH = [UIScreen mainScreen].bounds.size.height / 3.0;
progress = offsetY / screenH;
progress = progress-0.3;
if (progress > ) {
[self.interactiveTransition updateInteractiveTransition:progress];
} }
- (void)new_scrollViewWillEndDragging {
if (progress < 0.4) {
[self.interactiveTransition cancelInteractiveTransition];
}else {
[self.interactiveTransition finishInteractiveTransition];
}
self.interactiveTransition = nil;
} - (nullable id <UIViewControllerAnimatedTransitioning>)animationControllerForPresentedController:(UIViewController *)presented presentingController:(UIViewController *)presenting sourceController:(UIViewController *)source { return self.animation;
} - (id<UIViewControllerInteractiveTransitioning>)interactionControllerForPresentation:(id<UIViewControllerAnimatedTransitioning>)animator { return self.interactiveTransition;
}
PresentAnimation 类继承NSObject 实现 UIViewControllerAnimatedTransitioning协议
- (NSTimeInterval)transitionDuration:(id<UIViewControllerContextTransitioning>)transitionContext {
return 1.0;
} - (void)animateTransition:(id<UIViewControllerContextTransitioning>)transitionContext { UIView *toView = [transitionContext viewForKey:UITransitionContextToViewKey];
UIView *containerView = [transitionContext containerView];
[containerView addSubview:toView]; toView.frame = CGRectMake(, containerView.bounds.size.height, containerView.bounds.size.width - , containerView.bounds.size.height - ); [UIView animateWithDuration:[self transitionDuration:transitionContext] animations:^{
toView.frame = containerView.bounds;
}completion:^(BOOL finished) {
[transitionContext completeTransition:![transitionContext transitionWasCancelled]];
}]; }
控制器:
- (InteractiveTransition *)interactive {
if (!_interactive) {
_interactive = [[InteractiveTransition alloc]initWithPresentingController:self presentedController:[[TwoViewController alloc]init]];
}
return _interactive;
}
- (void)scrollViewWillBeginDragging:(UIScrollView *)scrollView { [self.interactive new_scrollViewWillBeginDragging:scrollView];
} - (void)scrollViewWillEndDragging:(UIScrollView *)scrollView withVelocity:(CGPoint)velocity targetContentOffset:(inout CGPoint *)targetContentOffset { [self.interactive new_scrollViewWillEndDragging];
}
- (void)scrollViewDidScroll:(UIScrollView *)scrollView { [self.interactive new_scrollViewDidScroll:scrollView];
}
完整代码:http://pan.baidu.com/s/1i3Uewip
上拉、下拉UITableView,交互式 模态弹出(自定义弹出动画)的更多相关文章
- [BS-23] AFN网络请求上拉/下拉刷新的细节问题总结
上拉/下拉刷新的细节问题总结 1.如果导航栏有透明色,则也需要设置header自动改变透明度 self.tableView.mj_header.automaticallyChangeAlpha = Y ...
- Swiper 判断上滑下拉操作
onTouchMove: function(swiper){ //手动滑动中触发//判断上滑下拉var i = mySwiper.translate;setTimeout(function() {va ...
- ios position:fixed 上滑下拉抖动
ios position:fixed 上滑下拉抖动 最近呢遇到一个ios的兼容问题,界面是需要一个头底部的固定的效果,用的position:fixed定位布局,写完测试发现安卓手机正常的,按时ios上 ...
- 浅谈对MJRefresh(上)下拉刷新控件的理解
MJRefresh GitHub地址:https://github.com/CoderMJLee/MJRefresh 利用业余时间研究了一下iOS的开发,发现OC特定的语法方式吸引了我,而且iOS开发 ...
- jsp页面上的下拉框案例(Struts2)
<s:select></s:select>包含的属性有:list="" :name="" :value="" ...
- 160823、ionic上拉/下拉更新数据
<!DOCTYPE html> <html ng-app="myApp"> <head> <meta charset="UTF- ...
- js实现页面的上滑下拉功能
这两天做项目,用到了上滑和下拉的功能,主要是通过监听touchmove,touchstart,touchend三个事件去判断页面上滑状态还是下拉状态. 同时加一个知识点:有时在监听时会报错,这个错是这 ...
- SDI在自定义的工具栏上添加下拉控件
0.首先到自己的工具条上新建一个控件,并命名新ID 1.拷贝FlatComboBox.h和FlatComboBox.cpp到工程目录下 2.建立新类 class CTrackerToolBar : p ...
- 小程序 上啦下拉刷新window配置
"enablePullDownRefresh": "true" /** * 页面相关事件处理函数--监听用户下拉动作 */ onPullDownRefres ...
- git过期后,如何将新建的项目push到码云上而且下拉成功
1.在码云上创建一个项目: 2.打开STS(spring Tool Suite) 新建一个Maven(webapp)项目: 3.打开你的码云账号,把码云上的工程的URL复制: 4.重新在另一个目录 ...
随机推荐
- js单例模式
js实现单例模式,经常使用两种方法,一种是使用构造函数的静态属性中缓存该实例,另一种是将实例包装在闭包中. 第一种实现方式: //静态属性中单例模式 function Universe() { if ...
- 移动端常见的不同苹果手机media query汇总
在做手机网站的时候,我经常用百分比布局,但是经常在不同的手机显示的不同 比如说,一样的东西,在iphone4(s).5(s).6.plus中都会有不同显示 有时候也想有为了某个手机单独的做一些效果,来 ...
- git命令收集整理
git init # 初始化本地git仓库(创建新仓库) git config --global user.name "xxx" # 配置用户名 git config --glob ...
- 扩展vbox硬盘大小
1.使用VboxManage list hdds查看所有安装的虚拟机信息 2.找到你要扩展硬盘容量虚拟机的UUID,使用modifyhd命令扩展硬盘大小 VBoxManage modifyhd U ...
- C语言学习中容易模糊的一些概念
1.什么叫分配内存 操作系统把某一块内存空间的使用权利分配给该程序 2.释放内存 操作系统把分配给该程序的内存空间的使用权利收回,该程序就不能再使用这块内存空间 注:释放内存空间并不是把这块内存的数据 ...
- Scala学习文档-列表的使用
注:列表是不可变的,不能通过赋值改变列表的元素 列表具有递归结构,数组是连续的 scala里的列表类型是协变的? --> scala中的逆变与协变 分治原则 //自定义实现:::操作符 def ...
- VirtualBox虚拟机无法选择桥接方式
VirtualBox 装好之后默认的网络是NAT模式,但这种模式中虚拟机配置的IP和主机的不再同一网段内,无法获得和主机一样的局域网地位,更不可能从主机用远程桌面携带硬盘的方式远程控制.而最简便的方法 ...
- linux crond服务
linux crond服务 linux crond服务简介:定时执行系统命令 查看crond服务状态:[root@www ~]# /sbin/service crond status 启动.停止.重启 ...
- Oracle left查询案例
)) summoney from( select t2.ano,d.dmoney from ( select t1.*,c.cno from( select a.ano,b.bno from t_a ...
- Keil C51内存分配与优化
C51的内存分配不同于一般的PC,内存空间有限,采用覆盖和共享技术.在Keil编译器中,经过编译后,会形成一个M51文件,在其内部可以详细的看到内存的分配情况. C51内存常见的两个误区: A.变量超 ...