1

在我的项目中,我必须创建某种特定的动画。这个想法是我必须移动两个 UILabel,它们都应该下降,但最初一个在另一个之上。最初我还有一个矩形区域,底部 UILabel 位于其中,当动画开始时,它应该看起来像两个 UILabel 都在某种旋转轮上,当它下降时,底部的消失(因为它再也不能通过那个矩形窗口看到了),顶部的窗口取而代之。

我试图通过定时 UILabel 的淡入和淡出来达到这种效果,但这看起来真的很糟糕。我想解决它的唯一方法是为矩形周围的区域设置动画,但只在该区域显示动画。你能给我一些建议吗?

这是一张照片:

这是一张照片:

这是一些代码,我试图这样做以实现这一点:

[UIView animateWithDuration:0.3 animations:^{
encouragementLabel.alpha = 1.0;
encouragementLabel.center = CGPointMake(encouragementLabel.center.x,encouragementLabel.center.y+40);}];

[UIView animateWithDuration:0.3 animations:^{
answer.alpha = 0;
answer.center = CGPointMake(answer.center.x, answer.center.y+40);}];
4

2 回答 2

1

尝试将标签添加为矩形视图的子视图。确保矩形视图的clipsToBounds属性或layer.masksToBounds设置为 YES,这将隐藏矩形边界之外的任何子视图。现在,当您为标签设置动画时,它们会在离开矩形后自动隐藏,并在进入矩形时出现。

于 2013-02-08T01:24:02.930 回答
0

你可以简单地试试这个......

[UIView animateWithDuration:0.3 animations:^{
       encouragementLabel.alpha = 1.0;
       encouragementLabel.center = 
           CGPointMake(encouragementLabel.center.x,encouragementLabel.center.y+40);
} completion:^(BOOL finished) {
       [UIView animateWithDuration:0.3 animations:^{
       answer.alpha = 0;
       answer.center = CGPointMake(answer.center.x, answer.center.y+40);}];
}];
于 2013-03-04T12:31:04.127 回答