gpt4 book ai didi

ios - UIView.animateWithDuration 越界

转载 作者:行者123 更新时间:2023-11-29 00:53:35 28 4
gpt4 key购买 nike

我正在尝试为一些 textfield 设置动画。即在屏幕外开始动画并移动到屏幕中央。但就我而言,动画从中心开始并超出 bounds。当我在 viewWillAppear/viewDidAppear 中声明这一点时,就会发生这种情况,但在 viewDidLoad 中,所有工作都很好/

override func viewWillAppear(animated: Bool) {
emailField.center.x -= view.bounds.width
}

override func viewDidAppear(animated: Bool) {

UIView.animateWithDuration(0.5, delay: 0.4, options: [], animations: {
self.emailField.center.x += self.view.bounds.width
}, completion: nil)

}

最佳答案

您可以尝试为变换属性设置动画。

override func viewWillAppear(animated: Bool) {
emailField.transform = CGAffineTransformMakeTranslation(-view.bounds.width, 0.0)
}

override func viewDidAppear(animated: Bool) {
UIView.animateWithDuration(0.5, delay: 0.4, options: [], animations: {
self.emailField.transform = CGAffineTransformIdentity
}, completion: nil)
}

关于ios - UIView.animateWithDuration 越界,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37853477/

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