I'm coding a shake image function, and the code is below:
CABasicAnimation* shake = [CABasicAnimation animationWithKeyPath:@"transform.rotation.z"];
shake.fromValue = [NSNumber numberWithFloat:-0.2];
shake.toValue = [NSNumber numberWithFloat:+0.2];
shake.duration = 0.1;
shake.autoreverses = YES;
shake.repeatCount = 4;
[self.imageView.layer addAnimation:shake forKey:@"imageView"];
self.imageView.alpha = 1.0;
[UIView animateWithDuration:2.0 delay:2.0 options:UIViewAnimationOptionCurveEaseIn animations:nil completion:nil];
I have two questions:
1.the code above will shake the image around its center(transform.rotation.z).But how to make the image shake around the bottom center?
2.How can I control the start and stop of this shaking animation? For example, make the image shaking until get data from server finished then stop the animation.