1,设置progressView的宽度(进度条长度)
通常情况下,我们可以在初始化 progressView的时候通过 frame属性设置其宽度(进度条长度)。
比如下面样例,我在屏幕中放置一个横向宽度是200的进度条,其位置是水平居中。
import UIKit
class ViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
//将背景设为黑色
self.view.backgroundColor = UIColor.blackColor()
//创建一个宽度是200的进度条
let myProgressView = UIProgressView(frame: CGRectMake(0, 0, 200, 10))
//设置进度条位置(水平居中)
myProgressView.layer.position = CGPoint(x: self.view.frame.width/2, y: 100)
//进度条条进度
myProgressView.progress = 0.3
//把进度条添加到view中来
self.view.addSubview(myProgressView)
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
}
}
2,设置progress