2015-11-04 89 views
0

目前,我尝试在自定义的工作赛格瑞它应该看起来像:定制Segue公司正确的方式

[目标视图]应该是后面的[来源查看],这[来源查看]应该从100%动画下降到0.1%,然后删除,在动画时间[Destination View]也应该在后台。
因此,您看到[源视图]在[目的地视图]前变小并被移除。

这是我的代码:

import UIKit 

class CustomSegueFromBigtoSmall: UIStoryboardSegue { 

    override func perform() { 

     let sourceVC = self.sourceViewController 
     let destinationVC = self.destinationViewController 

     sourceVC.view.addSubview(destinationVC.view) 

     UIView.animateWithDuration(0.5, delay: 0.0, options: .CurveEaseInOut, animations: {() -> Void in 

      sourceVC.view.transform = CGAffineTransformMakeScale(0.1, 0.1) 

      }){ (finished) -> Void in 

       destinationVC.view.removeFromSuperview() 

       let time = dispatch_time(DISPATCH_TIME_NOW, Int64(0.001 * Double(NSEC_PER_SEC))) 

       dispatch_after(time, dispatch_get_main_queue(), {() -> Void in 
        sourceVC.presentViewController(destinationVC, animated: false, completion: nil) 
       }) 
     } 

    } 

} 

现在,我看到我的[来源查看],那瞬间就变成我的[目标视图]。
[目标视图]在黑色背景前变小。一旦它“小”,它就会显示为全屏。

回答

0

我会在iOS 9中这样做的方式是使这个演示文稿(模态)segue与自定义segue实现。您的自定义赛格然后只需拨打super.perform()即可进行实际演示。但首先,segue将其自身设置为目的地transitionDelegate,并将其演示风格设置为Custom。现在,您只需执行一个普通的自定义过渡动画,使用您自己的过渡委托和您自己的UIPresentationController,并且您可以按照自己的想法按顺序执行任何操作。

+0

示例(来自我的书)在这里:https://github.com/mattneub/Programming-iOS-Book-Examples/blob/master/bk2ch06p325customSegue/CustomSegue/ViewController.swift – matt