アプリで UIButton を動的に作成しています。ボタンを表示するときは、アニメーション化したいです。このコードでボタンをアニメーション化できないようです:
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];
}
「forView:gridButton」を「forView:self.view」に変更すると、ビュー全体が反転しますが、個々のボタンは反転しません。個々のボタンを反転させたいだけです。
助けてくれてありがとう。