【发布时间】:2021-12-23 02:44:46
【问题描述】:
我正在尝试制作动画,但我不知道我做错了什么。我希望动画能够使菜单在向下滚动时放大,但由于在完成放大后会受到限制,它会继续剪辑。
我尽我所知尝试改变顺序,或者只是为了保持顶部固定,但直到现在我都没有成功。
(请参阅 Imgur 链接以获取我的意思的 gif 文件,即位置的突然跳跃)
menuHeightConstraint 是 UIView 高度的约束
IBAction函数代码
@IBAction func openMenu() {
menuIsOpen.toggle()
menuHeightConstraint.constant = menuIsOpen ? 180 : 55
logoHorizontalConstraint.constant = menuIsOpen ? 0 : -122
logoVerticalConstraint.constant = menuIsOpen ? 15 : 7
logoHeight.constant = menuIsOpen ? 75 : 40
logoWidth.constant = menuIsOpen ? 75 : 40
loginVertConstraint.constant = menuIsOpen ? 100 : 15 // label constraint
let indicator = menuIsOpen ? UIImage(systemName: "arrow.up.circle.fill") : UIImage(systemName: "arrow.down.circle.fill")
dropDownButtonImage.setImage(indicator, for: .normal)
UIView.animate(
withDuration: 0.5,
delay: 0,
options: .curveEaseIn,
animations: {
self.menuView.layoutIfNeeded()
},
completion: nil)
}
【问题讨论】:
标签: ios swift uiviewanimation