首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Swift iOS14设置约束动画

Swift iOS14设置约束动画
EN

Stack Overflow用户
提问于 2020-10-08 04:13:30
回答 1查看 62关注 0票数 0

我正在尝试对视图的底部约束进行动画处理,使其向上滑动。

这就是我正在做的,但它只是立即跳到新的位置,它不会滑动:

代码语言:javascript
复制
UIView.animate(withDuration: 0.4) {
    self.pickerBottomConstraint.constant += 300
    self.agePicker.setNeedsLayout()
    self.agePicker.layoutIfNeeded()
}

有人知道如何在iOS14中为约束设置动画吗?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2020-10-08 04:23:18

你需要

代码语言:javascript
复制
self.pickerBottomConstraint.constant += 300 // this should be outside of animate
UIView.animate(withDuration: 0.4) { 
   self.view.layoutIfNeeded()  // this should be called for at least the direct parent of the animated picker 
} 
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/64251651

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档