I have a problem that hopefully has a simple solution. I am trying to create a bobbing effect using a button, a timer, frame, cgaffinetransformrotations, and delays. Everything would be great, except that when the button is rotated and I set the frame of the button to decrease or increase the y by 10 or so pixels, the rotation makes the frame of the button bigger than it normally is. The end result is a button that constantly grows until it swallows the screen.
I tried making the upward and downward movements cgaffinetranslations, but that uses the transform property (which is the same one that the rotations use). The result is a very jumpy and non-realistic bob.
What I am trying to accomplish is just to set the origin component of the frame without having to specify a width and height, because even specifying a hard-coded width and height still makes it shrink when it is rotating and grow when it is approaching equilibrium again.
Any ideas?
Thanks!
CODE:
- (void)movePlay{
[self performSelector:@selector(moveDown:) withObject:play];
[self performSelector:@selector(rotateRight:) withObject:play afterDelay:0];
[self performSelector:@selector(moveUp:) withObject:play afterDelay:0.5];
[self performSelector:@selector(rotateLeft:) withObject:play afterDelay:1];
}
- (void)moveUp:(UIButton*)log{
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:.5];
log.transform = CGAffineTransformMakeTranslation(0, -20);
[UIView commitAnimations];
}
- (void)rotateRight:(UIButton*)log{
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:1];
log.transform = CGAffineTransformMakeRotation(0.0174532925*10);
[UIView commitAnimations];
}