Hi I am creating a new class CNAnimations. The purpose of this class is to perform some simple animations with ease and without using the same code a lot of times. So, I would like it to behave like [UIView animateWithDuration...]. Should I create a singleton class and init it in the appdelegate and the access it: [CNAnimations moveRight:view] ? Is that correct? Please note that the class will be used by a lot of uilabels,textfields etc from different classes.
Simple code:
-(void)moveRL:(UIView*)view{
CAKeyframeAnimation * anim = [ CAKeyframeAnimation animationWithKeyPath:@"transform" ] ;
anim.values = @[ [ NSValue valueWithCATransform3D:CATransform3DMakeTranslation(-5.0f, 0.0f, 0.0f) ], [ NSValue valueWithCATransform3D:CATransform3DMakeTranslation(5.0f, 0.0f, 0.0f) ] ] ;
anim.autoreverses = YES ;
anim.repeatCount = 2.0f ;
anim.duration = 2.0f ;
[view.layer addAnimation:anim forKey:nil ] ;
}