【问题标题】:CALayer CABasicAnimation opacityCALayer CABasicAnimation 不透明度
【发布时间】:2017-04-05 07:56:20
【问题描述】:

我已经创建了一个动画,但我无法使持续时间属性工作。

let animationFadeOut = CABasicAnimation(keyPath: "opacity")
animationFadeOut.fromValue = 1
animationFadeOut.toValue = 0
animationFadeOut.duration = 1
imageViewDos.layer?.add(animationFadeOut, forKey: nil)

无论我设置什么值,它始终具有相同的持续时间。

【问题讨论】:

  • 你已经设置了 animationFadeOut 的值并且你正在使用 animationFadeIn
  • 我制作了两种动画,FadeIn 和 FadeOut。粘贴是错误的。更新。对不起。

标签: swift3 calayer


【解决方案1】:

您的fromValue 和toValue 需要定义为NSNumbers

animationFadeOut.fromValue = NSNumber(floatLiteral: 1)
animationFadeOut.toValue = NSNumber(floatLiteral: 0)

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2012-09-09
    • 2011-10-11
    • 2011-02-02
    • 2011-11-26
    • 2011-12-19
    • 2014-07-11
    • 2014-01-05
    • 1970-01-01
    相关资源
    最近更新 更多