【问题标题】:IOS- move multiple images in upward direction vertically [duplicate]IOS-垂直向上移动多个图像[重复]
【发布时间】:2014-04-02 18:56:49
【问题描述】:

我是 IOS 编程新手。我想向上移动多个图像,以便图像向上然后从屏幕底部返回。所以目前我成功地将一张图像向上移动。但我不知道如何添加多个图像并将其向上移动

我要显示的图像名称: image01 image02 image03 image04 image05 image06

这是我的代码

- (void)viewDidLoad
{
    [super viewDidLoad];

    self.myImageView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 560, 320, 100)];
    [self.myImageView setImage:[UIImage imageNamed:@"image01.jpeg"]];
    [self.view addSubview:self.myImageView];
    [self setImages];
}
-(void)setImages
{
    for(int i=1;i<5;i++)
    {

        float height = self.myImageView.center.y-0.15;
        if(height<-130){

            height=self.view.frame.size.height;
        }
        self.myImageView.center = CGPointMake (self.myImageView.center.x, height);
        NSLog([NSString stringWithFormat:@"Height is %f",height]);
    }

    [self performSelector:@selector(setImages) withObject:nil afterDelay:0.03];
}

【问题讨论】:

  • 与其重复问同样的问题,我建议您使用新的详细信息编辑原件。

标签: ios xcode uiimageview core-animation


【解决方案1】:

你完全错了。

你需要:

1) 滚动视图;

2) 为每个图像单独的 ImageViews 作为具有适当框架的滚动视图的子视图。

3) 设置合适的scrollView contentSize

4) 通过动画改变 scrollView 的内容偏移量来滚动图像。

【讨论】:

  • 我不认为你已经理解我的问题。我不需要在我的屏幕上滚动视图。我想用动画向上移动所有图像。用户不必点击屏幕。就像我在后台使用这个屏幕一样,图像会不断上升。
猜你喜欢
  • 2021-01-04
  • 1970-01-01
  • 2014-09-25
  • 2013-02-19
  • 1970-01-01
  • 1970-01-01
  • 2014-05-13
  • 2017-02-25
  • 1970-01-01
相关资源
最近更新 更多