import UIKit
var imageView:UIImageView!
class ViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
//创建ProgressView
let progressView = UIProgressView(progressViewStyle: .default)
progressView.frame = CGRect(x: 150, y: 250, width: 200, height: 0)//自定义高度无效,默认为2.0,可通过transform改变高度
progressView.transform = CGAffineTransform(scaleX: 1.0, y: 3.0)
//设置默认进度
progressView.progress = 0.1
//设置进度,同时有动画效果
progressView.setProgress(0.8, animated: true)
//设置UIProgressView颜色
progressView.progressTintColor = UIColor.red//设置加载进度条颜色
progressView.trackTintColor = UIColor.gray//设置进度槽颜色
//将ProgressViewj添加到视图
self.view.addSubview(progressView)
}
}
原文地址:https://www.cnblogs.com/iOS-Development/p/10227475.html
时间: 2024-10-18 17:13:40