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
Post a Comment