【问题标题】:UIView animation not working - Xcode (Swift)UIView 动画不起作用 - Xcode (Swift)
【发布时间】:2020-10-01 17:50:52
【问题描述】:

示例: 我没有看到任何动画。为什么?

UIView.animate(withDuration: 1, delay: 0, options: [.repeat, .autoreverse], animations: {
    self.buttonTrial.transform = CGAffineTransform(scaleX: 1.2, y: 1.2)
}, completion: { completion in
    self.buttonTrial.transform = .identity
})

【问题讨论】:

  • 需要更多信息!你想为初学者做什么?有autoLayout吗?你的用户界面是什么样的?
  • @Rikh 我用storyboard,想要得到脉动动画的效果
  • 一件事,完成块是不必要的,因为它是重复动画,无论如何都不会调用完成块。但这不应该阻止动画的工作。除此之外,代码看起来很好,应该可以工作。
  • 你是否在你的代码中触发了这个动画块?例如。 on buttonTrial tap?

标签: ios swift xcode uiview


【解决方案1】:

您的代码运行良好。我删除了completion,因为它不是必需的,但除此之外,这是使用您显示的代码完全完成的。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2011-02-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多