【发布时间】:2018-10-04 20:32:59
【问题描述】:
我正在尝试创建一个垂直进度条。但问题是我的代码在 IOS11 或更高版本 上运行,但在 IOS9 上却无法运行。
在 IOS11 或更高版本上,它看起来像: enter image description here
但在 IOS9 上看起来像:enter image description here
我的代码:
let progressBar: UIProgressView = {
let prgressView = UIProgressView()
prgressView.progress = 0.7
prgressView.progressTintColor = UIColor(red: 1.0, green: 0.21, blue: 0.33, alpha: 1)
prgressView.trackTintColor = UIColor.blue
prgressView.layer.cornerRadius = 6.5
prgressView.clipsToBounds = true
prgressView.transform = CGAffineTransform(rotationAngle: .pi / -2)
prgressView.translatesAutoresizingMaskIntoConstraints = false
return prgressView
}()
layoutSubview()
override func layoutSubviews() {
super.layoutSubviews()
let width = progressBar.bounds.width
let height = progressBar.bounds.height
progressBar.bounds.size.width = height
progressBar.bounds.size.height = width
}
viewDidLoad()
self.addSubview(progressBar)
progressBar.centerXAnchor.constraint(equalTo: self.centerXAnchor).isActive = true
progressBar.centerYAnchor.constraint(equalTo: self.centerYAnchor).isActive = true
progressBar.widthAnchor.constraint(equalToConstant: 22.5).isActive = true
progressBar.heightAnchor.constraint(equalToConstant: 250).isActive = true
我正在按照本教程创建垂直进度视图:https://www.youtube.com/watch?v=ifekgTtb0rQ&t=1070s
【问题讨论】:
-
截至 2018 年 9 月 3 日,95% of devices are iOS10 or higher 所以.. 为什么要出汗?只需设置您的最低 iOS 版本即可。这不像Android,人们可以随意选择操作系统。一旦人们收到有新版本的通知,他们通常会安装它。而且没有回头路。
标签: ios swift uiprogressview