标签:des style blog color 文件 width
自定义segue需要继承 UIStoryboardSegue类,然后重写-(void)perform;方法.在方法中可以自定义转场动画。
</pre><span style="color: rgb(97, 34, 174); font-family: Courier; font-size: 18px;">CoolSegue.h文件</span><p></p><p></p><pre code_snippet_id="420043" snippet_file_name="blog_20140707_2_5708153" name="code" class="objc">#import <UIKit/UIKit.h> @interface CoolSegue : UIStoryboardSegue @end
CoolSegue.m文件
#import "CoolSegue.h"
@implementation CoolSegue
-(void)perform
{
UIViewController* source = self.sourceViewController;
UIViewController* destination = self.destinationViewController;
UIGraphicsBeginImageContext(destination.view.bounds.size);
CGContextRef contextRef = UIGraphicsGetCurrentContext();
[destination.view.layer renderInContext:contextRef];
UIImage* desImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
UIImageView* iView = [[UIImageView alloc] initWithImage:desImage];
[iView setBackgroundColor:[UIColor grayColor]];
iView.autoresizingMask = UIViewAutoresizingFlexibleWidth|UIViewAutoresizingFlexibleHeight;
iView.contentMode = UIViewContentModeCenter;
[source.parentViewController.view addSubview:iView];
CGAffineTransform scaleT = CGAffineTransformMakeScale(0.1, 0.1);
CGAffineTransform rotateT = CGAffineTransformMakeRotation(M_PI);
//iView.transform = CGAffineTransformConcat(scaleT, rotateT);
iView.transform =CGAffineTransformTranslate(CGAffineTransformConcat(scaleT, rotateT), 1, 1);
CGPoint originPoint = iView.center;
iView.center = CGPointMake(iView.bounds.size.width, iView.bounds.size.height);
//iView.center = CGPointMake(originPoint.x -iView.bounds.size.width, originPoint.y);
[UIView animateKeyframesWithDuration:0.8 delay:0 options:UIViewKeyframeAnimationOptionCalculationModeCubic animations:^{
iView.transform = CGAffineTransformIdentity;
iView.center = originPoint;
}completion:^(BOOL finished) {
[self.sourceViewController presentViewController:self.destinationViewController animated:YES completion:nil];
[iView removeFromSuperview];
}];
}
iOS自定义segue和自定义segue转场动画,布布扣,bubuko.com
标签:des style blog color 文件 width
原文地址:http://blog.csdn.net/shouqiangwei/article/details/37507171