I try this in viewDidAppear but i have a one second of delay =( what can i do? for work in viewDidLoad?
-(void)viewDidAppear:(BOOL)animated{
fullRotation = [CABasicAnimation animationWithKeyPath:@"transform.rotation"];
fullRotation.fromValue = [NSNumber numberWithFloat:0];
fullRotation.toValue = [NSNumber numberWithFloat:((720*M_PI)/360)];
fullRotation.duration = 5;
// fullRotation.repeatCount = 1e10f;
[_propImaCirculoCompleto.layer addAnimation:fullRotation forKey:@"360"];
}
You shouldn't do any animation in
viewDidLoad
as the view won't have a superview yet so the animation is irrelevant.A few thoughts on your code sample:
You can use
viewDidAppear
as long as you want the animation every time the view appears, not just the first time it is presented.Using Core Animation within an animation block isn't necessary. Do one or the other.
Suggestions
If you are trying to animate the appearance of a view managed by a different view controller, the presenting controller is responsible for the animation. There are a few ways to implement this depending on your minimum supported version of iOS.
In iOS 5+ you can use a custom container controller to present a child view controller with a defined animation.
In iOS 7 you can use 'presentViewController:animated:completion' and specify a custom animation. You would then set the
transitioningDelegate
property and have the delegate provide the animator for the transition.I don't have ready sample code for the above but that's what I would look at.
Try to split Your animation by two 180 degree rotations. Seems that iOS 7 is lazy and wan't rotate by 360 :)