Storyboard 自定义转场动画
在storyboard中,segue有几种不同的类型,在iphone和ipad的开发中,segue的类型是不同的。在iphone中,segue 有:push,modal,和custom三种不同的类型,这些类型的区别在与新页面出现的方式。而在ipad中,有 push,modal,popover,replace和custom五种不同的类型。
1 自定义DetailStoryboardSegue类继承于UIStoryboardSegue
// 这个类用于处理跳转动画
- (instancetype)initWithIdentifier:(NSString *)identifier source:(UIViewController *)source destination:(UIViewController *)destination
{
self = [super initWithIdentifier:identifier source:source destination:destination];
if (self)
{
}
return self;
}
- (void)perform
{
// 如果使用系统的转场动画则不注释,如果使用自定义转场动画则重写该放法。
// [super perform];
// 自定义转成动画代码部分
UIViewController *source = self.sourceViewController;
UIViewController *destination = self.destinationViewController;
// Create a UIImage with the contents of the destination
UIGraphicsBeginImageContext(destination.view.bounds.size);
[destination.view.layer renderInContext:UIGraphicsGetCurrentContext()];
UIImage *destinationImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
// Add this image as a subview to the tab bar controller
UIImageView *destinationImageView = [[UIImageView alloc] initWithImage:destinationImage];
[source.parentViewController.view addSubview:destinationImageView];
// Scale the image down and rotate it 180 degrees (upside down)
CGAffineTransform scaleTransform = CGAffineTransformMakeScale(0.1, 0.1);
CGAffineTransform rotateTransform = CGAffineTransformMakeRotation(M_PI);
destinationImageView.transform = CGAffineTransformConcat(scaleTransform, rotateTransform);
// Move the image outside the visible area
CGPoint oldCenter = destinationImageView.center;
CGPoint newCenter = CGPointMake(oldCenter.x - destinationImageView.bounds.size.width, oldCenter.y);
destinationImageView.center = newCenter;
// Start the animation
[UIView animateWithDuration:0.5f
delay:
options:UIViewAnimationOptionCurveEaseOut
animations:^(void) {
destinationImageView.transform = CGAffineTransformIdentity;
destinationImageView.center = oldCenter;
}
completion: ^(BOOL done) {
// Remove the image as we no longer need it
[destinationImageView removeFromSuperview];
// Properly present the new screen
[source.navigationController pushViewController:destination animated:nil];
}];
}
2 在Storyboard中设置

Storyboard 自定义转场动画的更多相关文章
- iOS自定义转场动画实战讲解
iOS自定义转场动画实战讲解 转场动画这事,说简单也简单,可以通过presentViewController:animated:completion:和dismissViewControllerA ...
- Swift开发小技巧--自定义转场动画
自定义转场动画 个人理解为重写了被弹出控制器的modal样式,根据自己的样式来显示modal出来的控制器 例:presentViewController(aVC, animated: true, co ...
- 第六十五篇、OC_iOS7 自定义转场动画push pop
自定义转场动画,在iOS7及以上的版本才开始出现的,在一些应用中,我们常常需要定制自定义的的跳转动画 1.遵守协议:<UIViewControllerAnimatedTransitioning& ...
- iOS自定义转场动画的实现
iOS中熟悉的是导航栏中的push和pop这两种动画效果,在这里我们可以自己实现自己想要的一些转场动画 下面是我自己创建转场动画的过程 1.新建一个文件继承自NSObject ,遵循协议UIViewC ...
- 一行代码实现自定义转场动画--iOS自定义转场动画集
WXSTransition 这款非常不错,力推 这是作者源码简书地址: http://www.jianshu.com/p/fd3154946919 这是作者源码github地址 https://git ...
- iOS 自定义转场动画
代码地址如下:http://www.demodashi.com/demo/12955.html 一.总效果 本文记录分享下自定义转场动画的实现方法,具体到动画效果:新浪微博图集浏览转场效果.手势过渡动 ...
- iOS 自定义转场动画浅谈
代码地址如下:http://www.demodashi.com/demo/11612.html 路漫漫其修远兮,吾将上下而求索 前记 想研究自定义转场动画很久了,时间就像海绵,挤一挤还是有的,花了差不 ...
- swift项目第八天:自定义转场动画以及设置titleView的状态
如图效果: 一:Home控制器 /* 总结:1:设置登陆状态下的导航栏的左右按钮:1:在viewDidLoad里用三目运算根据从父类继承的islogin的登陆标识来判断用户是否登陆来显示不同的界面.未 ...
- iOS开发自定义转场动画
1.转场动画 iOS7之后开发者可以自定义界面切换的转场动画,就是在模态弹出(present.dismiss),Navigation的(push.pop),TabBar的系统切换效果之外自定义切换动画 ...
随机推荐
- html5新增标签集锦
<keygen></keygen><meter low="69" high="80" max="100" op ...
- linux 驱动入门3
不吃苦中苦,难为人上人.努力,给老婆孩子提供个良好的生活居住环境. http://www.cnblogs.com/nan-jing/articles/5806399.html 上文提到.可以自动创建了 ...
- mysql数据库中间件研究
随着互联网的发展,数据量的不断增大. 单台实例已经远远无法满足业务的需要. 对数据库分库分表的需求不断的增加随之而来的就是数据库中间件的开发. 一. 单台实例主要面临下面几个问题: 1. 数据量太大 ...
- Listener
通过Listner获得当前的用户个数 package listener; import javax.servlet.ServletContext; import javax.servlet.Servl ...
- Dom编程(二)
document是window对象的一个属性,因为使用window对象成员的时候可以省略window.,所以一般直接写document document的方法: (1)write:向文档中写入内容. ...
- BZOJ 3101: N皇后
3101: N皇后 Time Limit: 10 Sec Memory Limit: 128 MBSec Special JudgeSubmit: 178 Solved: 94[Submit][ ...
- MySQL常用命令(参考资料,部分改动)
一.连接MYSQL 格式: mysql -h主机地址 -u用户名 -p用户密码 . 连接到本机上的MYSQL. 首先打开DOS窗口,然后进入目录mysql\bin,再键入命令mysql -u root ...
- 2782: [HNOI2006]最短母串
2782: [HNOI2006]最短母串 Time Limit: 1 Sec Memory Limit: 128 MBSubmit: 3 Solved: 2[Submit][Status][Web ...
- 微软2017MVP大礼包拆箱攻略
容我本周偷个懒,晒个大礼包就糊弄过去了.13号晚上拿到的大礼包,激动的没敢拆,一直等到娃睡着了,才偷偷打开了快递,忍了两天没忍住,上来晒图得瑟一下,请各位轻拍,谢谢! 1.大礼包的盒子(联邦快递的盒子 ...
- 用JS添加文本框案例代码
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/ ...