gpt4 book ai didi

ios - UIStoryboardSegue:顶 View 没有向下滑动

转载 作者:行者123 更新时间:2023-11-28 07:02:04 26 4
gpt4 key购买 nike

我有以下 swift 代码,我想要实现的是从顶部滑出的 segue。我希望第二个 VCView 位于第一个 VCView 下方,并且让第一个 VCView 滑出显示第二个 VCView。

目前没有动画,只是闪烁到第二个VCView。

非常感谢

import UIKit

class TopToBottomSegue: UIStoryboardSegue {

override func perform() {

// Assign the source and destination views to local variables.
var firstVCView = self.sourceViewController.view as UIView!
var secondVCView = self.destinationViewController.view as UIView!

// Get the screen width and height.
let screenWidth = UIScreen.mainScreen().bounds.size.width
let screenHeight = UIScreen.mainScreen().bounds.size.height

// Specify the initial position of the destination view.
secondVCView.frame = CGRectMake(0, 0, screenWidth, screenHeight)

// Access the app's key window and insert the destination view below the current (source) one.
let window = UIApplication.sharedApplication().keyWindow
window?.insertSubview(secondVCView, belowSubview: firstVCView)

// Animate the transition.
UIView.animateWithDuration(0.4, animations: { () -> Void in

firstVCView.frame = CGRectOffset(firstVCView.frame, 0.0, screenHeight)
//secondVCView.frame = CGRectOffset(secondVCView.frame, -screenWidth, 0.0)

}) { (Finished) -> Void in
self.sourceViewController.presentViewController(self.destinationViewController as! UIViewController,
animated: false,
completion: nil)
}

}
}

最佳答案

据我所知,您需要在 animateWithduration block 中调用 layoutIfNeeded 以获得流畅的动画。

问候

关于ios - UIStoryboardSegue:顶 View 没有向下滑动,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31804175/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com