ios - Drawing an infinite sine wave -


i'm trying make animated sine wave similar solution: https://stackoverflow.com/a/17535290

i'm trying make sine wave continuous i'm drawing same sine wave. in solution above, once starting point of wave equal width of frame, view restarts drawing new wave.

can explain cgaffinetransformmaketranslation(+_self_view.frame.size.width/2, 0); in code below? understanding returns matrix shifts x-axis right half frame size. don't understand how causes animation does.

-(void)animatewave {     [uiview animatewithduration:.5 delay:0.0 options:uiviewanimationoptionrepeat|uiviewanimationoptioncurvelinear animations:^{     _self_view.transform = cgaffinetransformmaketranslation(+_self_view.frame.size.width/2, 0);     } completion:^(bool finished) {     _self_view.transform = cgaffinetransformmaketranslation(0, 0);     }]; } 

there 2 views involved. there “sine wave” view, , there superview (parent) of sine wave view.

suppose superview 320 points wide - width of iphone screen.

make sine wave view 640 points, , draw two cycles of sine wave in it. each cycle 320 points wide. left 320 points of sine wave view right 320 points.

now position sine wave view in superview frame.x of -320. means right 320 points of sine wave view visible:

initial view arrangement

now animate sine wave view right 320 points (half of width):

animating

when animation finishes, visible part of sine wave view looks identical part visible before animation:

complete

if @ point reset sine wave view initial position (instantly, without animation), user won't able tell, because visible pixels won't change:

reset

the effect of uiviewanimationoptionrepeat reset animated parameters original states , start animation over. if arrange sine wave view , superview described, seamless loop.


Comments

Popular posts from this blog

commonjs - How to write a typescript definition file for a node module that exports a function? -

openid - Okta: Failed to get authorization code through API call -

ios - Change Storyboard View using Seague -