2011-08-21 94 views
0

我要翻转,并使用动画展开按钮翻转和规模扩大按钮动画

代码:

[UIView beginAnimations:nil context:nil]; 
[UIView setAnimationDuration:5.0]; 
[UIView setAnimationTransition:UIViewAnimationTransitionFlipFromRight forView:mybutton cache:YES]; 
[mybutton setFrame:CGRectMake(mybutton.frame.origin.x, mybutton.frame.origin.x, 200, 200)]; 
[UIView commitAnimations]; 

有这个动画问题:
- 巴顿被翻转,但它的半圆后扩大翻转。
- 按钮位置翻转后不准确。

我该如何解决?

回答

0

尝试完全评论setFrame,它应该翻转得更好。也尝试将缓存设置为NO。根据文档,你不应该修改在动画本身过渡的视图 - cache:NO会有所帮助,但它仍然是不正确的。

你通常有一个给setAnimationTransition函数的父视图,然后在取出旧的子视图并将其从子视图中移除后,然后添加新的子视图。这给出了一个孩子子视图翻转的幻觉,并且新孩子被翻转为焦点。转换发生在父项上,尽管包含子项。

无论哪种方式,请尝试注释setFrame一分钟,它应该看起来更一致。

0

因为它们都是独立的动画,你也可以尝试使用,一旦动画完成,其被称为AnimationDidStopSelector;)

哦顺便说一句,在你CGRectMake您使用y坐标的X轴再次协调,这可能就是为什么位置是不准确的^^

这样类似的东西:

- (void)yourFunction { 
    [UIView beginAnimations:nil context:indexPath]; 
    [UIView setAnimationDuration:0.3]; 
    [UIView setAnimationDelegate:self]; 
    [UIView setAnimationDidStopSelector:@selector(functionEnded:finished:context:)]; 
    [UIView setAnimationTransition:UIViewAnimationTransitionFlipFromRight forView:mybutton cache:YES]; 
    [UIView commitAnimations]; 
} 

- (void)functionEnded:(NSString *)animationID finished:(NSNumber *)finished context:(void *)context { 
     [UIView beginAnimations:nil context:indexPath]; 
     [UIView setAnimationDuration:1.3]; 
     [mybutton setFrame:CGRectMake(mybutton.frame.origin.x, mybutton.frame.origin.y, 200, 200)]; 
     [UIView commitAnimations]; 
} 
+0

我需要的按钮,翻转,并在同一时间扩大。 示例:在iPad上打开iTunes,然后单击一首歌曲。 – Houranis