Xcode iPhone的UIBUtton标题动画
我想把一个动画自定义UIButton的标题,使数字(每个标题显示一个随机分配的数字)将来旋转。我该怎么做Xcode iPhone的UIBUtton标题动画,xcode,animation,uibutton,Xcode,Animation,Uibutton,我想把一个动画自定义UIButton的标题,使数字(每个标题显示一个随机分配的数字)将来旋转。我该怎么做 问题是我不想使用翻转数字图像来实现这一点。我想知道是否还有其他方法。假设您有一个名为flipLabelButton的按钮作为IBOutlet连接到视图控制器,您可以使用此代码将按钮设置为新标签的动画: - (IBAction)flipLabelText:(id)sender { NSString *newText = [NSString stringWithFormat:@"%d",
问题是我不想使用翻转数字图像来实现这一点。我想知道是否还有其他方法。假设您有一个名为
flipLabelButton
的按钮作为IBOutlet
连接到视图控制器,您可以使用此代码将按钮设置为新标签的动画:
- (IBAction)flipLabelText:(id)sender {
NSString *newText = [NSString stringWithFormat:@"%d", rand() % 100];
[UIView beginAnimations:@"flipbutton" context:NULL];
[UIView setAnimationDuration:1.0];
[UIView setAnimationTransition:UIViewAnimationTransitionFlipFromRight forView:self.flipLabelButton cache:YES];
[self.flipLabelButton setTitle:newText forState:UIControlStateNormal];
[UIView commitAnimations];
}
假设有一个名为
flipLabelButton
的按钮作为IBOutlet
连接到视图控制器,则可以使用此代码将按钮动画化为新标签:
- (IBAction)flipLabelText:(id)sender {
NSString *newText = [NSString stringWithFormat:@"%d", rand() % 100];
[UIView beginAnimations:@"flipbutton" context:NULL];
[UIView setAnimationDuration:1.0];
[UIView setAnimationTransition:UIViewAnimationTransitionFlipFromRight forView:self.flipLabelButton cache:YES];
[self.flipLabelButton setTitle:newText forState:UIControlStateNormal];
[UIView commitAnimations];
}