想知道如何换一个UILabel

问题描述:

如果对这个问题有一个愚蠢简单的答案,我很抱歉,但我一直在网上寻找一个简单而直接的答案,而且还没有真正得到一个答案。我想要做的就是在iPad屏幕上将UILabel从一个地方移到另一个地方。我不希望它是瞬间的,我希望它是动画,所以我该怎么做?任何帮助(对于愚蠢的问题很有耐心^ _ ^;)将不胜感激!想知道如何换一个UILabel

[UIView beginAnimations:@"myMoveAnimation" context:nil]; 
aUIButton.center = CGMakePoint(newX, newY); 
[UIView commitAnimations]; 

对于拉姆达爱好者...

[UIView animateWithDuration:secondsToTake delay:0 
     options: UIViewAnimationOptionCurveEaseIn 
     animations:^{ 
      aUIButton.center = CGPointMake(newX, newY); 
     } 
     completion:^(BOOL finished){ /* Some code for to run when complete /* }]; 
+0

谢谢!我想我对UIView部分感到困惑。我不知道可以像这样应用于UILabel。 – RaysonK 2011-05-30 19:37:21

+0

仅供将来参考...块的动画是将允许从ios 4的动画的唯一类型... ... – learner2010 2011-05-31 13:54:12

+0

@ learner2010:不完全。 “在iOS 4.0及更高版本中不鼓励使用此方法”,但这不是“允许”的问题 - 它们只是警告我们它将被弃用(可能在iOS 5中)。 – 2011-05-31 14:18:48