gpt4 book ai didi

ios - UITextView 上的(缩放)变换动画

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

我的目标是为嵌套在以模态方式呈现的 UIView 卡中的 UITextView 创建“冒泡”动画。

当卡片出现时,UITextView 似乎没有出现......是否有一些解决方法?下面是我迄今为止尝试过的代码...

override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
DispatchQueue.main.async {
UIView.animate(withDuration: 1, delay: 0.1, usingSpringWithDamping: 0.7, initialSpringVelocity: 0.8, options: .curveEaseOut, animations: {
self.cardView.transform = CGAffineTransform(scaleX: 1, y: 1)
self.messageTextView.transform = CGAffineTransform(scaleX: 1, y: 1)
}, completion: nil)
}
}

override func viewDidLoad() {
super.viewDidLoad()
cardView.transform = CGAffineTransform(scaleX: 0, y: 0)
messageTextView.transform = CGAffineTransform(scaleX: 0, y: 0)
}

最佳答案

我不确定确切的设置,所以显示 Storyboard。我没有添加约束,而是在动画之前添加 setNeedsLayout 。希望它对您有用。

enter image description here

          override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
DispatchQueue.main.async {
self.messageTextView.setNeedsLayout()
UIView.animate(withDuration: 1, delay: 0.1, usingSpringWithDamping: 0.7, initialSpringVelocity: 0.8, options: .curveEaseOut, animations: {
self.cardView.transform = CGAffineTransform(scaleX: 1, y: 1)
self.messageTextView.transform = CGAffineTransform(scaleX: 1, y: 1)
}, completion: nil)
}
}

enter image description here

关于ios - UITextView 上的(缩放)变换动画,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53199547/

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