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的系统切换效果之外自定义切换动画 ...
随机推荐
- HDU 4044 GeoDefense
树形DP,和背包差不多.dp[now][x]表示now这个节点的子树上,花费为x的时候,获得的最大防御能力(保证敌方HP<=0) #include<cstdio> #include& ...
- Codeforces#362
A题 题意:给定一串数列,t,t+s,t+s+1,t+2s,t+2s+1......问某一个数是否是数列当中的 题意:只需判断(x-t)与(x-t-1)能否整除s即可,注意起始时的判断 #includ ...
- Android SQLite 加入自定义函数
SQLite Database 自定义函数实现: //Here's how to create a function that finds the first character of a strin ...
- Jquery的AJAX应用详解
案例一:取得服务端当前时间 简单形式:jQuery对象.load(url),返回结果自动添加到jQuery对象代表的标签中间 <body> 当前时间: <span id=" ...
- http://begin.lydsy.com/JudgeOnline/problem.php?id=2770(PKU2503 Babelfish)
2770: PKU2503 Babelfish Time Limit: 1 Sec Memory Limit: 128 MBSubmit: 2 Solved: 2[Submit][Status][ ...
- Javascript 浮点运算问题分析与解决
分析 JavaScript 只有一种数字类型 Number ,而且在Javascript中所有的数字都是以IEEE-754标准格式表示的. 浮点数的精度问题不是JavaScript特有的,因为有些小数 ...
- Android中服务的生命周期回调方法
- Unity UGUI —— 无限循环List
还记得大学毕业刚工作的时候是做flash的开发,那时候看到别人写的各种各样的UI组件就非常佩服,后来自己也慢慢尝试着写,发现其实也就那么回事.UI的开发其实技术的成分相对来说不算多,但是一个好的UI是 ...
- Mysql中常用的函数汇总
Mysql中常用的函数汇总: 一.数学函数abs(x) 返回x的绝对值bin(x) 返回x的二进制(oct返回八进制,hex返回十六进制)ceiling(x) 返回大于x的最小整数值exp(x) 返回 ...
- 【spoj LCS2】 Longest Common Substring II
http://www.spoj.com/problems/LCS2/ (题目链接) 题意 求多个串的最长公共子串 Solution 对其中一个串构造后缀自动机,然后其它串在上面跑匹配.对于每个串都可以 ...