Swift UIImageView和UISlider组合

/***************火焰图片Demo************start*******/

var imgView: UIImageView?

override func viewDidLoad() {

super.viewDidLoad()

let screenWidth = UIScreen.mainScreen().bounds.size.width

imgView = UIImageView(frame: CGRect(x: 20, y: 100, width: screenWidth - 20 * 2, height: screenWidth - 20 * 2))

imgView!.backgroundColor = UIColor.redColor()

self.view.addSubview(imgView!)

// 初始化数组

var imgs:[UIImage] = []

for index in 1...17 {

let imgName = NSString(format: "campfire%02d.gif", index)

if let img:UIImage = UIImage(named: imgName as String) {

// 按图片添加到数组中  append功能是直接添加到数组的lastobject

imgs.append(img)

}

}

imgView?.animationImages = imgs

imgView?.animationDuration = 1

imgView?.startAnimating()

let slider = UISlider(frame: CGRect(x: 20, y: 100 + imgView!.frame.size.height + 50, width: imgView!.frame.size.width, height: 30))

slider.value = 0.5

slider.addTarget(self, action: "sliderAction:", forControlEvents: UIControlEvents.ValueChanged)

self.view.addSubview(slider)

}

// MARK: slider 的拖动tart的方法

func sliderAction(slider: UISlider) {

imgView?.animationDuration = NSTimeInterval(slider.value * 2)

imgView?.startAnimating()

}

/***************火焰图片Demo************start*******/

上一篇:图像处理------泛洪填充算法(Flood Fill Algorithm) 油漆桶功能


下一篇:asp.net mvc cshtml (VIEWS)中怎么提供URL参数: