I'm dynamically creating UIButton's in my app. When I show the buttons I want to animate them. I can't seem to get the buttons to animate with this code:
UIImage *buttonBackground = [UIImage imageNamed:@"ButtonRed.png"];
for (NSInteger x = 0; x < 4; x++) {
CGRect btnFrame = CGRectMake(x * (buttonBackground.size.width+2),
y * (buttonBackground.size.height + 1),
buttonBackground.size.width,
buttonBackground.size.height);
UIButton *gridButton = [[[UIButton alloc] initWithFrame: btnFrame] retain];
[gridButton setBackgroundImage:buttonBackground forState:UIControlStateNormal];
[buttonBackground release];
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:.5];
[UIView setAnimationTransition:UIViewAnimationTransitionFlipFromLeft forView:gridButton cache:YES];
[self.view addSubview:gridButton];
[UIView commitAnimations];
[gridButton release];
}
If I change the "forView:gridButton" to "forView:self.view", then the whole view flips but but not the individual buttons. I just want each individual button to flip.
Thanks for any help.