Swift UI - 进度条(UIProgressView)

注:代码已升级至Swift4

创建进度条

1
2
3
4
let progressView = UIProgressView(progressViewStyle: .default)
progressView.center = self.view.center
progressView.progress = 0.5 //默认进度50%
self.view.addSubview(progressView)

设置进度,同时有动画效果

1
progressView.setProgress(0.8, animated:true)

改变进度条颜色

1
2
progressView.progressTintColor = UIColor.green  //已有进度颜色
progressView.trackTintColor = UIColor.blue //剩余进度颜色(即进度槽颜色)

Powered by AppBlog.CN     浙ICP备14037229号

Copyright © 2012 - 2020 APP开发技术博客 All Rights Reserved.

访客数 : | 访问量 :