0
我要創建使用核心動畫像動畫:iOS版的Core Animation:顯示和隱藏效果
- 圖片A從1秒到3秒顯示。 3秒後,隱藏它。
- 圖片B顯示從5秒到7秒。 7s後,隱藏它。
我的代碼:
var animation = CABasicAnimation(keyPath: "opacity")
animation.duration = 3.0
// animate from fully visible to invisible
animation.fromValue = NSNumber(float: 1.0)
animation.toValue = NSNumber(float: 0.0)
animation.beginTime = 2
animation.removedOnCompletion = true
layer1.addAnimation(animation, forKey: "animateOpacity")
animation = CABasicAnimation(keyPath: "opacity")
animation.duration = 3.0
// animate from fully visible to invisible
animation.fromValue = NSNumber(float: 1.0)
animation.toValue = NSNumber(float: 0.0)
animation.beginTime = 5
animation.removedOnCompletion = true
layer2.addAnimation(animation, forKey: "animateOpacity")
我如何能實現呢?謝謝:)
可以顯示烏爾試圖代碼 –
在同一圖像視圖?如果沒有任何東西可以顯示,從0到1s以及3s到5s之間,你會希望圖像爲空 –
@nbubu:我添加了我的代碼,請刷新看看:) –