【发布时间】:2016-01-06 06:33:11
【问题描述】:
我有 UIButton,我想向它添加一个连续闪烁/更改边框颜色动画。所以它应该从没有边框颜色开始,然后在 1 秒后变为绿色,然后重复。
我该怎么做?
【问题讨论】:
标签: ios swift animation uibutton
我有 UIButton,我想向它添加一个连续闪烁/更改边框颜色动画。所以它应该从没有边框颜色开始,然后在 1 秒后变为绿色,然后重复。
我该怎么做?
【问题讨论】:
标签: ios swift animation uibutton
希望对你有帮助
targetButton.layer.borderWidth = 8.0
let color: CABasicAnimation = CABasicAnimation(keyPath: "borderColor")
color.fromValue = UIColor.clearColor().CGColor
color.toValue = UIColor.greenColor().CGColor
color.duration = 0.5
color.autoreverses = true
self.targetButton.layer.borderColor = UIColor.clearColor().CGColor
self.targetButton.layer.addAnimation(color, forKey: "")
抱歉,我忘了设置按钮边框宽度。 你可以再试一次。
【讨论】: