[英]Custom UIViewController transitions with animateWithDuration in Swift
所以......事实是,我几乎盲目地浏览文档。 我真的不明白为什么没有示例代码说明如何使用某些方法。 但是,是的,还有我的抱怨。
我有一个符合UIViewControllerTransitioningDelegate和UIViewControllerAnimatedTransitioning的视图控制器。 我有一些动画(使用facebook pop)基本上可以滑出视图的某些元素。 完成这些动画后,我想转换到下一个视图控制器。
我已经覆盖了prepareForSegue,如下所示:
override func prepareForSegue(segue: UIStoryboardSegue!, sender: AnyObject!) {
self.transitioningDelegate = self;
let targetViewController = self.storyboard.instantiateViewControllerWithIdentifier("chooseSigilViewController") as UIViewController;
self.presentViewController(targetViewController, animated: true, completion: nil);
// slide out ui elements in the current UIViewController
slideLabelsOut(greetingsLabel, nameUtilityLabel);
slideTextFieldOut(inputPlayerNameTextField);
slideProceedButtonOut(sender as UIButton); }
我设置转换持续时间和实际动画...我遇到的问题是这一行:
UIView.animateWithDuration(self.transitionDuration(transitionContext), animations: <#(() -> Void)?#>, completion: <#((Bool) -> Void)?#>)
如何在动画中设置我的代码:和完成:参数。
我在Obj-C代码中看到过这个:
^{ // code goes here }
我试过这种方式,它没用。 它也觉得很尴尬,因为我真的不知道“^”甚至是什么?
尝试这样的事情:
UIView.animateWithDuration(self.transitionDuration(transitionContext), delay: 0, options: .CurveLinear, animations: {
// Your animation
}, completion: {
(finished: Bool) in
// Your completion
})
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.