【问题标题】:Animate UIView grow from left rather than center动画 UIView 从左侧而不是中心增长
【发布时间】:2020-02-20 22:15:49
【问题描述】:

UIView button 的宽度为 44,它应该以动画方式展开到 90。目前,当动画开始时,它会将视图重新对齐到 44 宽度的中心,然后将左右两侧都展开到 90。

self.button.widthConstraint?.isActive = false
self.button.width(90)
UIView.animate(
  withDuration: animationDuration,
  animations: {
    self.layoutIfNeeded()
  }
)

如何仅从右侧对展开进行动画处理?我希望左边被固定,而右边增加它的 x 位置。

【问题讨论】:

    标签: ios swift animation uiview


    【解决方案1】:

    设置您的约束,以便固定前导、尾随、顶部和底部锚点,然后为尾随约束的更改设置动画。

    【讨论】:

    • 如何固定锚点?这是cgaffinetransform
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2012-06-02
    • 1970-01-01
    • 2015-11-22
    • 2021-11-28
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多