在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中设置

最新文章

  1. 视图(View) – ASP.NET MVC 4 系列
  2. 从C#到Objective-C,循序渐进学习苹果开发(5)--利用XCode来进行IOS的程序开发
  3. 编写高性能Javascript代码的若干建议
  4. Linux下的一个图形管理工具webmin
  5. jQuery Mobile 移动开发中的日期插件Mobiscroll使用说明
  6. 使用 eclipse+egit 将项目提交至 github ,本地的git仓库:eclipse工作项目目录
  7. 当月 当年sql
  8. python2.7抓取豆瓣电影top250
  9. JavaScript高级程序设计39.pdf
  10. final关键字的作用
  11. [Cocos2d-x]Lua 资源热更新
  12. Linux程序设计综合训练之简易Web服务器
  13. 定时跳转的两种方式(html + javaweb)
  14. Day 5-4封装.__隐藏属性或者方法
  15. Django 学习第三式
  16. 移动APP漏洞趋势
  17. [javaSE] 基本类型(String相关)
  18. September 21st 2017 Week 38th Thursday
  19. 北京Uber优步司机奖励政策(11月2日~11月8日)
  20. HDU 5116 Everlasting L

热门文章

  1. (简单) POJ 2251 Dungeon Master,BFS。
  2. JAVA基础--单例模式
  3. 苹果应用商店AppStore审核中文指南
  4. Kconfig基本语法
  5. iOS自定义字体及类目 分类: ios技术 2015-05-15 16:34 195人阅读 评论(0) 收藏
  6. X-007 FriendlyARM tiny4412 u-boot移植之内存初始化
  7. python threading模块中对于信号的抓取
  8. mysql 省市联动sql 语句
  9. 获取IIS版本
  10. Iphone安装铃声