UIButton Transition Curl Up问题

时间:2010-03-16 10:55:54

标签: iphone objective-c iphone-sdk-3.0

基本上,我正在尝试UIViewAnimationTransitionCurlUp一个UIButton。动画 按钮效果很好但按钮停留在那里。

即。按钮向上卷曲,但按钮的另一个实例仍位于下方。

我的代码如下:

[UIButton beginAnimations:nil context:nil];
[UIButton setAnimationDuration:0.5];
[UIButton setAnimationBeginsFromCurrentState:YES];
[UIButton setAnimationTransition:UIViewAnimationTransitionCurlUp forView:self.view cache:YES];
[UIButton commitAnimations];

3 个答案:

答案 0 :(得分:6)

+beginAnimations+commitAnimations来电之间设置新按钮状态。以下代码隐藏了带卷曲动画的点击按钮:

- (void)btnClick:(id)sender{
    [UIButton beginAnimations:nil context:nil];
    [UIButton setAnimationDuration:0.5];
    [UIButton setAnimationBeginsFromCurrentState:YES];
    [UIButton setAnimationTransition:UIViewAnimationTransitionCurlUp 
                                  forView:(UIView*)sender cache:YES];
    ((UIView*)sender).hidden = YES;

    [UIButton commitAnimations];
}

答案 1 :(得分:2)

动画结束时你必须删除按钮(隐藏按钮)。这应该在

中完成
- (void)animationDidStop:(NSString *)animationID finished:(NSNumber *)finished context:(void *)context

应该在动画代码中设置

像:

[UIButton setAnimationDidStopSelector:@selector(animationDidStop:finished:context:)];

希望这有帮助。

谢谢,

Madhup

答案 2 :(得分:0)

好吧,在我投票给你之前我应该​​检查一下......

动画结束后按钮不消失:(

我的代码现在是:

[UIButton beginAnimations:@"welcomeAnimation" context:nil];
[UIButton setAnimationDuration:0.5];
[UIButton setAnimationDidStopSelector:@selector(welcomeAnimationDidStop:finished:context:)];
[UIButton setAnimationBeginsFromCurrentState:YES];
[UIButton setAnimationTransition:UIViewAnimationTransitionCurlUp forView:self.view cache:YES];
[UIButton commitAnimations];

和我的方法:

-(void)welcomeAnimationDidStop:(NSString *)animationID finished:(BOOL *)finished context:(void *)context {
   welcomeButton.hidden = YES;
}