【问题标题】:how to add images into UIView如何将图像添加到 UIView
【发布时间】:2011-04-04 06:48:29
【问题描述】:

我有 4 张图片。我想在 UIView 中一张一张地添加图像。 请给我任何想法。如何在 UIView 中添加图像数组。

【问题讨论】:

  • 你想为这些图像制作动画吗?
  • 是的,我想一张一张地为这个图像数组制作动画
  • 我想在每张图片上添加 Ken Burns 效果
  • 您必须在我的代码中设置图像视图的框架并更改高度和宽度而不是 x 和 y...(我提供的答案)

标签: uiview


【解决方案1】:

你的问题并不清楚,但我猜你想在延迟一段时间后一张一张地在你的视图中显示图像......如果这是你想要的,你可以通过

[self performSelector:@selector(callFunction) withObject:nil afterDelay:0 ];
[self performSelector:@selector(callFunction2) withObject:nil afterDelay:k_AnimateTime ];
[self performSelector:@selector(callFunction3) withObject:nil afterDelay:2*k_AnimateTime ];

在函数中

imageview = [[[UIImageView alloc] initWithFrame:CGRectMake(x,y,w,h)]autorelease];
    imageview.image = [[UIImage imageNamed: [NSString stringWithString:name]]autorelease];
    [self.view addSubview:imageview];
    imageview.frame = CGRectMake(imageview.frame.origin.x, (imageview.frame.origin.y), imageview.frame.size.width, imageview.frame.size.height);
    [UIView beginAnimations:nil context:NULL];
    [UIView setAnimationDelegate:self];
    //[UIView setAnimationWillStartSelector:@selector(Transform2)];


    [UIView setAnimationDuration:k_AnimateTime];

    [UIView setAnimationBeginsFromCurrentState:YES];
    //[UIView setAnimationDidStopSelector:@selector(increaseCount)];
    imageview.frame = CGRectMake(imageview.frame.origin.x - Ex, (imageview.frame.origin.y - Ey), imageview.frame.size.width, imageview.frame.size.height);
    [UIView commitAnimations];

    [self.view addSubview:imageview];

}

【讨论】:

  • 所有动画完成后如何重复功能?
  • 从超级视图中删除所有图像并再次调用相同的函数
猜你喜欢
  • 2016-10-04
  • 1970-01-01
  • 2014-08-23
  • 2023-03-21
  • 2014-05-16
  • 2019-05-09
  • 2021-05-07
  • 2023-04-05
  • 2018-12-09
相关资源
最近更新 更多