swift animation does not go through all keyframes -
i want go through red -> green -> blue, when add 3 colors, go through last 2 colors:
var duration = 6.0 uiview.animatekeyframeswithduration(duration, delay: 1.0, options: uiviewkeyframeanimationoptions.repeat | uiviewkeyframeanimationoptions.autoreverse, animations: { () -> void in self.colortransition.backgroundcolor = uicolor.redcolor() self.colortransition.backgroundcolor = uicolor.greencolor() self.colortransition.backgroundcolor = uicolor.bluecolor() }, completion: nil)
you have call addkeyframewithrelativestarttime each of 3 transitions, specifying when start , how long.
for example:
uiview.animatekeyframeswithduration(duration, delay: 1.0, options: .repeat | .autoreverse, animations: { uiview.addkeyframewithrelativestarttime(0, relativeduration: 0.33) { self.colortransition.backgroundcolor = uicolor.redcolor() } uiview.addkeyframewithrelativestarttime(0.33, relativeduration: 0.33) { self.colortransition.backgroundcolor = uicolor.greencolor() } uiview.addkeyframewithrelativestarttime(0.66, relativeduration: 0.34) { self.colortransition.backgroundcolor = uicolor.bluecolor() } }, completion: nil)
Comments
Post a Comment