swift UISlider,UIProgressView
//
// SliderViewController.swift
// UIControlDemo
//
// Created by on 14/12/4.
// Copyright (c) 2014年 马大哈. All rights reserved.
//
import UIKit
class SliderViewController: BaseViewController {
var slider: UISlider?
var progress: UIProgressView?
override func viewDidLoad() {
super.viewDidLoad()
progress = UIProgressView(frame: CGRectMake(20, 300, self.view.frame.size.width-40, 50))
progress?.progressViewStyle = UIProgressViewStyle.Default //两种不同的样式
progress?.progressTintColor = .redColor()// 不断改变的进度条颜色 (默认 蓝色)
progress?.trackTintColor = .blackColor() // 可以认为是底色(默认 灰色)
self.view.addSubview(progress!)
slider = UISlider(frame: CGRectMake(20, 400, self.view.frame.size.width-40, 50))
slider?.minimumValue = 1
slider?.maximumValue = 100
slider?.addTarget(self, action: "valueChanged:", forControlEvents: UIControlEvents.ValueChanged)
self.view.addSubview(slider!)
}
func valueChanged(sender:UISlider){
let value = "\(Int(sender.value))"
self.title = value
progress?.progress = sender.value/100
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
}