如何为作为子视图的UITextView设置动画?

时间:2011-01-28 03:41:33

标签: iphone animation uiscrollview uitextview

我正在尝试动画UITextView(myTextView),它是UIScrollView(scrollView)中的子视图。

[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:1];
[UIView setAnimationTransition:UIViewAnimationTransitionCurlDown forView:myTextView cache:YES];
[scrollView addSubview:myTextView];
[UIView commitAnimations];

myTextView没有动画显示!

2 个答案:

答案 0 :(得分:1)

你想做什么样的动画?例如,如果你想淡入,你必须这样做


[scrollView addSubview:myTextView];
myTextView.alpha = 0.0;
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:1];
[UIView setAnimationTransition:UIViewAnimationTransitionCurlDown forView:myTextView cache:YES];
myTextView.alpha = 1.0;
[UIView commitAnimations];

您可以更改多个属性(例如:frame,transform)以制作动画。

答案 1 :(得分:0)

http://www.4shared.com/dir/-PGqZEXR/zoominzoomout.html只需在项目中添加此文件,然后通过此函数调用

这里im2是UIVIEW,我在上面粘贴图像然后通过视图传递这个

- (void)viewDidLoad {
     [self loadFlowersInView:im2];
     [self.view addSubview:im2];
} 

现在像这样附加这个功能

- (void) loadFlowersInView: (UIView *) backdrop { 
      NSString *create_button = nil; // Add the flowers to random points on the screen
      for (int i = 0; i < 1; i++) { 
           MagPicAppDelegate *appdelegate = (MagPicAppDelegate *)[[UIApplication sharedApplication] delegate];
           NSString *whichFlower = appdelegate.imageName;
           UIImage *stemp = [UIImage imageNamed:@"approve.png"];
           DragView *dragger = [[DragView alloc] initWithImage:stemp];
           dragger.userInteractionEnabled = YES;
           dragger.center = CGPointMake(160.0f, 140.0f);
           [im2 addSubview:dragger];
           [dragger release];
      }

      [self.view addSubview:im2]; 
      [im2 release];
}