objective c - CABasicAnimation progress with variable speed -


i need calculate progress of cabasicanimation @ time t in order update progress view.

when progress linear, calculate elapsed time @ each time (thanks https://stackoverflow.com/a/20993376/2268168).

the thing is, animation not linear, speed variable.

speed up

mylayer.timeoffset = [mylayer converttime:cacurrentmediatime() fromlayer:nil]; mylayer.begintime = cacurrentmediatime(); mylayer.speed=2; speed = 2; 

slow down

mylayer.timeoffset = [mylayer converttime:cacurrentmediatime() fromlayer:nil]; mylayer.begintime = cacurrentmediatime(); mylayer.speed=0.5; speed = 0.5; 

how can calculate progress of animation taking account variable speed ?

i tried this, seems work when speed increases once.

cftimeinterval elapsedtime = (cacurrentmediatime() - animation.begintime);  cftimeinterval remainingtime = (totalduration - elapsedtime)/speed; speed = 1; totalduration = remainingtime+elapsedtime;  float progress = (totalduration-remainingtime)/totalduration; 

am doing wrong ?

thanks help!

thanks @danh pointing me answer core animation progress callback.

it helped me.

i added subclassed calayer, animated same way animated layer (with same speed variations). way, can progress of main animation.


Comments

Popular posts from this blog

javascript - Slick Slider width recalculation -

jsf - PrimeFaces Datatable - What is f:facet actually doing? -

angular2 services - Angular 2 RC 4 Http post not firing -