Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/xcode/7.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Xcode iPhone的UIBUtton标题动画_Xcode_Animation_Uibutton - Fatal编程技术网

Xcode iPhone的UIBUtton标题动画

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

我想把一个动画自定义UIButton的标题,使数字(每个标题显示一个随机分配的数字)将来旋转。我该怎么做


问题是我不想使用翻转数字图像来实现这一点。我想知道是否还有其他方法。

假设您有一个名为
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];
}