【发布时间】:2015-11-04 20:31:33
【问题描述】:
目前我尝试在自定义 segue 上工作,它应该如下所示:
[Destination View] 应该在 [Source View] 之后,这个 [Source View] 应该从 100% 动画到 0.1% 然后移除,在动画时间 [Destination View] 也应该在背景中.
因此,您会看到 [Source View] 在 [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)
})
}
}
}
现在我看到了我的 [Source View],它立即变成了我的 [Destination View]。
[Destination View] 在黑色背景前变小了。一旦它“小”,它就会显示为全屏。
【问题讨论】: