I’m trying to make an icon “shaking”.
On loading my controller I create a Timer like this:
[NSTimer scheduledTimerWithTimeInterval:0.2 target:self selector:@selector(shakeIphonePic) userInfo:nil repeats:YES];
And here’s my shaker method:
- (void)shakeIphonePic
{
[UIView animateWithDuration:0.09
delay:0
options:UIViewAnimationOptionAllowUserInteraction
animations:^{
self.iphonePic.layer.transform = CATransform3DMakeRotation(DegreesToRadians(8.0), 0.0, 0.0, 1.0);
}
completion:^(BOOL finished) {
[UIView animateWithDuration:0.09
animations:^(void) {
self.iphonePic.layer.transform = CATransform3DMakeRotation(DegreesToRadians(-16.0), 0.0, 0.0, 1.0);
}];
}
];
}
It’s not as nice as I expected but… this is not the main problem.
It looks like it dramatically slow down the rest of my UI, which before was good.
Can you suggest me a more efficient way to shake my icon?
Swift version