我有一个标签栏控制器和3个孩子,我还有另一个视图,我从子视图到视图控制器创建了一个自定义segue,还有一个从视图控制器到子视图的自定义展开segue。问题是,当展开正在进行时,标签栏会被隐藏,并在展开结束时显示。
这是一个GIF示例:
这是我自定义segue展开的代码:
import UIKit
class AddMeCustomSegueUnwind: UIStoryboardSegue {
override func perform() {
// Assign the source and destination views to local variables.
let secondVCView = self.sourceViewController.view as UIView!
let firstVCView = self.destinationViewController.view as UIView!
let screenHeight = UIScreen.mainScreen().bounds.size.height
let window = UIApplication.sharedApplication().keyWindow
//window?.insertSubview(firstVCView, aboveSubview: secondVCView)
//window?.insertSubview(firstVCView, belowSubview: secondVCView)
window?.insertSubview(firstVCView, atIndex: 0)
// Animate the transition.
UIView.animateWithDuration(0.4, animations: { () -> Void in
secondVCView.frame = CGRectOffset(secondVCView.frame, 0.0, -screenHeight + 64)
}) { (Finished) -> Void in
self.sourceViewController.dismissViewControllerAnimated(false, completion: nil)
}
}
}
答案 0 :(得分:2)
为了使展开工作正如我所说,展开segue需要从标签栏控制器完成,所以我创建了一个UITabBarController
并添加相同的展开。