首页 > 解决方案 > 为什么我的动画(有时)会覆盖 Xcode 13 中的选项卡栏控制器?

问题描述

我有一个 UITextView,它从屏幕外(下)开始制作动画。效果很好,除非我按下主页按钮并返回应用程序。然后,文本在选项卡栏控制器上滚动,并且不会停留在视图区域内。我正在运行 Xcode 13。问题发生在模拟器和我的 iPhone12 上。一如既往,我非常感谢您的帮助。这是我的代码:

导入 UIKit

类 InfoViewController: UIViewController {

@IBOutlet weak var helpText: UITextView!




override func viewWillAppear(_ animated: Bool) {
    super.viewWillAppear(animated)
    animate()
}

// ***************************************************************
// MARK: Animate text view from below screen
// ***************************************************************
func animate() {
    UIView.animate(withDuration: 4.0, delay: -0.0, options: []) {
        self.helpText.frame.origin.y -= 700
    }
}

// ***************************************************************
// MARK: Reset view so it properly animates during
// subsequent views/loads.
// ***************************************************************
override func viewWillDisappear(_ animated: Bool) {
    super.viewWillDisappear(animated)
    self.helpText.frame.origin.y += 700
}

}

以下是好操作和坏操作的示例:

工作示例。

失败的例子。

标签: animationxcode13

解决方案


推荐阅读