如何使用动画在iPhone初始屏幕上添加两个文本

时间:2013-09-10 12:32:49

标签: iphone ios

在我的应用程序启动画面中,我想做一些动画,比如移动文本,

  1. Text1 :从左向右移动。
  2. Text2 :从右向左移动。
  3. 如何在启动画面中间添加两个文本?

2 个答案:

答案 0 :(得分:1)

这就是你可以为任何UIElement制作动画的方法:

//create UILabel
UILabel* textLeft = [[[UILabel alloc] initWithFrame:CGRectMake(50, 50, 50, 50)] autorelease];
[self.view addSubview:textLeft];
textLeft.text = @"LEFT TEXT";
//get current position and size
CGRect targetFrame = textLeft.frame;
//change X coord to desired position
targetFrame.origin.x = 300.0f;
//animate
[UIView animateWithDuration:1 animations:^{textLeft.frame = targetFrame;}];

答案 1 :(得分:1)

我们无法直接在启动画面中添加任何自定义。以下想法可能对您有所帮助,请勿在应用中添加启动画面。首先在窗口中添加一个ViewController(它有两个文本字段和动画)。完成动画后,尝试删除viewcontroller并完成剩下的工作。

1。创建一个名为animatetext.h,.m的viewcontroller。

2。在animatetext.m中,viewdidload方法编写文本域动画代码。

3。接下来在appdelegate didfinishlaunchingwithoptions中编写代码,如self.window.rootviewcontroller = animatetextobject。

4。之后在animateview类中,在20秒后调用一个方法(如removeView)(textdus的Animationduration)。在removeView方法中写[self.view removeFromSuperView];在该行下方添加[appdelegate.window setRootViewController:someViewController];