ios - How to stop UIView CABasicAnimation in iPhone -


i have 3 views dynamically created using loop. in called below method rotation animation

- (void)runrightspinanimationonview:(uiview*)view duration:(cgfloat)duration rotations:    (cgfloat)rotations repeat:(float)repeat; {   cabasicanimation* rotationanimation;   rotationanimation = [cabasicanimation animationwithkeypath:@"transform.rotation"];   rotationanimation.fromvalue = [nsnumber numberwithfloat:0];   rotationanimation.tovalue = [nsnumber numberwithfloat:((360*m_pi)/180)];   //rotationanimation.tovalue = [nsnumber numberwithfloat: m_pi * 2.0 /* full rotation*/ * rotations * duration ];   rotationanimation.duration = duration;   //rotationanimation.cumulative = yes;   rotationanimation.repeatcount = repeat;   [view.layer addanimation:rotationanimation forkey:@"rotationanimation"]; } 

how can stop rotation animation in touch begin of view?... tried below coding in touch begin method didn't work

-(void)touchesbegan:(nsset *)touches withevent:(uievent *)event {    uitouch *touch = [touches anyobject];    int viewtag=[touch view].tag;    uiview *myview =(uiview *)[self.view viewwithtag:viewtag];    [myview.layer removeallanimations]; } 

please me...

it may because of removing animation other layer rather remove animation same layer added animation on. (you using wrong view remove animation, please check again).

you can use remove animation yourview:

[yourview.layer removeallanimations]; 

Comments

Popular posts from this blog

linux - Does gcc have any options to add version info in ELF binary file? -

android - send complex objects as post php java -

charts - What graph/dashboard product is facebook using in Dashboard: PUE & WUE -