gpt4 book ai didi

ios - 同步 UIViewController 转换动画

转载 作者:行者123 更新时间:2023-11-30 11:02:30 25 4
gpt4 key购买 nike

我正在尝试淡入背景渐变图像,并将 uiview 卡从底部(屏幕外)向上滑动到 uiviewcontroller 的中心 - 执行当 uiviewcontroller 以模态方式呈现时,两个动画同时出现。

我尝试的是将uiviewcontroller模态过渡样式设置为交叉溶解,这将为背景渐变图像提供淡入效果,并在viewDidAppear 运行动画将 uiview 卡从底部向上滑动到中心。

虽然这有效,但卡片有轻微的延迟,理想情况下我希望两个动画同时发生。

这个分组可能吗?任何指导将不胜感激。

下面是模态呈现的 View Controller 中的相关代码:

override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
alertViewCenterYConstraint.constant += view.bounds.height

}

override func viewDidAppear(_ animated: Bool) {
super.viewDidAppear(animated)
UIView.animate(withDuration: 0.1, delay: 0, options: .curveEaseOut, animations: {
self.alertViewCenterYConstraint.constant = 0
self.view.layoutIfNeeded()
}, completion: nil)
}

最佳答案

这就像魔术一样。我喜欢它。

   override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
alertViewCenterYConstraint.constant += view.bounds.height
DispatchQueue.main.async {
UIView.animate(withDuration: 0.1, delay: 0.05, options: .curveEaseOut, animations: {
self.alertViewCenterYConstraint.constant = 0
self.view.layoutIfNeeded()
}, completion: nil)

}
}

关于ios - 同步 UIViewController 转换动画,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53164130/

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