ios - Seamlessly updating a layer's visual property values after a `CAAnimationGroup` completes? -


i'm trying animate scale then opacity of calayer, so:

cabasicanimation *scaleup = [cabasicanimation animationwithkeypath:@"transform"]; scaleup.fromvalue = [nsvalue valuewithcatransform3d:self.timerprogresslayer.transform]; scaleup.tovalue = [nsvalue valuewithcatransform3d:catransform3dmakescale(1.0, 1.0, 1.0)]; scaleup.duration = 0.25; scaleup.fillmode = kcafillmodeforwards;  cabasicanimation *fadeout = [cabasicanimation animationwithkeypath:@"opacity"]; fadeout.fromvalue = @(1.0); fadeout.tovalue = @(0.0); fadeout.begintime = 0.3; fadeout.duration = 0.25; fadeout.fillmode = kcafillmodeforwards;  caanimationgroup *group = [caanimationgroup animation]; group.animations = @[scaleup, fadeout]; group.removedoncompletion = yes; group.duration = fadeout.begintime + fadeout.duration;  [self.timerprogresslayer addanimation:group forkey:@"trigger"]; 

that's simple enough, , animation works fine. however, @ end of animation it's removed , values revert ones @ beginning. combat this, set properties manually, after addanimation: call:

self.timerprogresslayer.opacity = 0.0; self.timerprogresslayer.transform = catransform3dmakescale(1.0, 1.0, 1.0); 

however, these calls override animation, , layer fades out , scales immediately. if use animation's delegate or [catransaction setcompletionblock:] set properties @ end of animation, lot of time (but not 100% of time), single frame of old state gets through between end of animation , properties being set.

how can use caanimationgroup animate properties, removing animation @ end without old values peeking through frame?

i've given the long version of answer previously. there no reason repeat detailed explanation here.

but short answer seeing layer's implicit animations being applied on top of explicit animation. have written a detailed explanation implicit , explicit animations , multiple simulations animation, if want read more it.


as described in "the long answer". solution problem update properties, temporarily disable implicit animations aren't applied on top of explicit animations:

[catransaction begin]; [catransaction setdisableactions:yes]; // actions disabled  self.timerprogresslayer.opacity = 0.0; self.timerprogresslayer.transform = catransform3dmakescale(1.0, 1.0, 1.0);  [catransaction commit];                // until here 

Comments

Popular posts from this blog

javascript - AngularJS custom datepicker directive -

javascript - jQuery date picker - Disable dates after the selection from the first date picker -