Start and stop animation with CABasicAnimation iphone -
i want use animation image, start on button clicked , stop after 5 seconds.i use code.
-(ibaction) btnclicked{ cabasicanimation *fullrotation = [cabasicanimation animationwithkeypath:@"transform.rotation"]; fullrotation.fromvalue = [nsnumber numberwithfloat:0]; fullrotation.tovalue = [nsnumber numberwithfloat:((360*m_pi)/180)]; fullrotation.duration = 6; fullrotation.repeatcount = 1e100f; fullrotation.delegate = self; [imgview.layer addanimation:fullrotation forkey:@"360"]; [imgview.layer setspeed:3.0]; }
with code animation started don't know how stop animation after 5 seconds.
dont deal coreanimation. think can done uiview animations, easier program. @ uiview docs , try block animations (assuming ios4.0. if not, use older style).
look @ http://developer.apple.com/library/ios/#documentation/windowsviews/conceptual/viewpg_iphoneos/animatingviews/animatingviews.html%23//apple_ref/doc/uid/tp40009503-ch6-sw1 docs on uiview animations. set transform property rotation using cgaffinetransformmakerotation
here uiview based animated rotation:
- (void)viewdidload { [super viewdidload]; uiview *v = [[[uiview alloc] initwithframe:cgrectmake(50, 50, 100, 100)] autorelease]; v.backgroundcolor = [uicolor bluecolor]; [self.view addsubview:v]; [uiview animatewithduration:5 animations:^{v.transform=cgaffinetransformmakerotation(m_pi);}];
}
Comments
Post a Comment