您的位置:首页 > 产品设计 > UI/UE

iOS --- 使用UIImageView来实现倒计时动画

2015-10-28 07:33 513 查看

UIImageView动画

UIImageView自身即提供了多个图片切换的动画效果,可用于实现倒计时等动画。

// these allow a set of images to be animated. the array may contain multiple copies of the same

public var animationImages: [UIImage]? // The array must contain UIImages. Setting hides the single image. default is nil
@available(iOS 3.0, *)
public var highlightedAnimationImages: [UIImage]? // The array must contain UIImages. Setting hides the single image. default is nil

public var animationDuration: NSTimeInterval // for one cycle of images. default is number of images * 1/30th of a second (i.e. 30 fps)
public var animationRepeatCount: Int // 0 means infinite (default is 0)

// When tintColor is non-nil, any template images set on the image view will be colorized with that color.
// The tintColor is inherited through the superview hierarchy. See UIView for more information.
@available(iOS 7.0, *)
public var tintColor: UIColor!

public func startAnimating()
public func stopAnimating()
public func isAnimating() -> Bool


倒计时动画的样例如下:

func imageViewAnimation() {
var images: Array = Array<UIImage>()
for var i in 1...10 {
images.append(UIImage(named: "\(i).jpg")!)
}
images = images.reverse()
imageView.animationImages = images
imageView.animationRepeatCount = 0
imageView.animationDuration = 10
imageView.startAnimating()
}


Demo

Demo地址: DemoAnimation
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  iOS ImageView 动画