如何使ImageView滚动无限

时间:2015-03-25 08:01:04

标签: objective-c swift

如何让这个imageview无休止地滚动,imageview在下一个图像视图跟踪第一个视频的地方重复出现?

此代码循环使用imageview:foodbg一次,但我希望它能无休止地循环:

// set up some constants for the animation
    let duration : NSTimeInterval = 5.0
    let delay : NSTimeInterval = 0.0
    let options = UIViewAnimationOptions.CurveLinear

    // create the background imageview and add it to the screen
    let foodbg = UIImageView()
    foodbg.image = UIImage(named: "foodbg5.png")
    foodbg.frame = CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height)
    self.view.addSubview(foodbg)


    var endBackgroundScroll: Bool = false
    // define the animation
    UIView.animateWithDuration(duration, delay: delay, options: options, animations: {
        // move the background
        foodbg.frame = CGRectMake(0, self.view.frame.size.height, self.view.frame.size.width, self.view.frame.size.height)
        }, completion: { animationFinished in
            // remove the background
            foodbg.removeFromSuperview()
    })

0 个答案:

没有答案