博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
更改navigationController push和pop界面切换动画
阅读量:5297 次
发布时间:2019-06-14

本文共 2015 字,大约阅读时间需要 6 分钟。

For Push:

MainView *nextView=[[MainView alloc] init];[UIView  beginAnimations:nil context:NULL];[UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];[UIView setAnimationDuration:0.75];[self.navigationController pushViewController:nextView animated:NO];[UIView setAnimationTransition:UIViewAnimationTransitionFlipFromRight forView:self.navigationController.view cache:NO];[UIView commitAnimations];[nextView release];

TwoDView *twoD  =[[TwoDView alloc]init];    CATransition *animation = [CATransition animation];    [animation setDuration:0.4];    [animation setType: kCATransitionPush];    [animation setSubtype: kCATransitionFromLeft];    [animation setTimingFunction:[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionDefault]];    [self.navigationController pushViewController:twoD animated:NO];    [self.navigationController.view.layer addAnimation:animation forKey:nil];    [twoD release];

For Pop:

方法一:

[UIView  beginAnimations:nil context:NULL];[UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];[UIView setAnimationDuration:0.75];[UIView setAnimationTransition:UIViewAnimationTransitionFlipFromLeft forView:self.navigationController.view cache:NO];[UIView commitAnimations];[UIView beginAnimations:nil context:NULL];[UIView setAnimationDelay:0.375];[self.navigationController popViewControllerAnimated:NO];[UIView commitAnimations];

方法二:

可实现左右滑动动画,可设置滑动方向。

CATransition* transition = [CATransition animation];transition.duration = 0.5;transition.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];transition.type = kCATransitionFade; //kCATransitionMoveIn; //, kCATransitionPush, kCATransitionReveal, kCATransitionFade//transition.subtype = kCATransitionFromTop; //kCATransitionFromLeft, kCATransitionFromRight, kCATransitionFromTop, kCATransitionFromBottom[self.navigationController.view.layer addAnimation:transition forKey:nil];[[self navigationController] popViewControllerAnimated:NO];

转载于:https://www.cnblogs.com/jiackyan/p/3380471.html

你可能感兴趣的文章
HDU4405--Aeroplane chess(概率dp)
查看>>
CS0103: The name ‘Scripts’ does not exist in the current context解决方法
查看>>
20130330java基础学习笔记-语句_for循环嵌套练习2
查看>>
Spring面试题
查看>>
窥视SP2010--第一章节--SP2010开发者路线图
查看>>
MVC,MVP 和 MVVM 的图示,区别
查看>>
C语言栈的实现
查看>>
代码为什么需要重构
查看>>
TC SRM 593 DIV1 250
查看>>
SRM 628 DIV2
查看>>
2018-2019-2 20165314『网络对抗技术』Exp5:MSF基础应用
查看>>
Python-S9-Day127-Scrapy爬虫框架2
查看>>
使用gitbash来链接mysql
查看>>
SecureCRT的使用方法和技巧(详细使用教程)
查看>>
右侧导航栏(动态添加数据到list)
查看>>
81、iOS本地推送与远程推送详解
查看>>
虚拟DOM
查看>>
uva 11468 Substring
查看>>
自建数据源(RSO2)、及数据源增强
查看>>
BootStrap2学习日记2--将固定布局换成响应式布局
查看>>