gpt4 book ai didi

ios - 自定义转场 : Going from Top to Bottom

转载 作者:行者123 更新时间:2023-11-29 01:38:59 26 4
gpt4 key购买 nike

我试图通过让源 View Controller 从上到下进行连接。我可以让过渡从上到下进行,但是当过渡发生时,有一个从上到下的黑色矩形。一旦完成,目标 View Controller 就会弹出。有人知道如何解决这个问题吗?我正在使用本教程:http://www.appcoda.com/custom-segue-animations/并改变它的一部分来完成我想要它做的事情。

import UIKit

class FirstCustomSegue: UIStoryboardSegue {
override func perform() {
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, 0, screenWidth, screenHeight)

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

// Animate the transition.
UIView.animateWithDuration(2, animations: { () -> Void in
firstVCView.frame = CGRectOffset(firstVCView.frame, 0.0, screenHeight)
secondVCView.frame = CGRectOffset(secondVCView.frame, 0.0, screenHeight)

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

}
}

最佳答案

像这样更新你的代码,它现在能正常工作了吗?

secondVCView.frame = CGRectMake(0.0, -screenHeight, screenWidth, screenHeight)

关于ios - 自定义转场 : Going from Top to Bottom,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32643855/

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