ios - 更改 UIProgressbar 的高度并给出边框和角半径
<p><p>目前,我正在使用 <code>UIProgressView</code>,我需要更改 <code>UIProgressView</code> 的高度。我通过下面的代码实现。</p>
<pre><code>extension UIProgressView {
@IBInspectable var barHeight : CGFloat {
get {
return transform.d * 2.0
}
set {
// 2.0 Refers to the default height of 2
let heightScale = newValue / 2.0
let c = center
transform = CGAffineTransform(scaleX: 1.0, y: heightScale)
center = c
self.layer.cornerRadius = 20.0
}
}
}
</code></pre>
<p>但是当我将 <code>cornerRadius</code> 设置为 <code>UIProgressView</code> 时不会受到影响。 </p></p>
<br><hr><h1><strong>Best Answer-推荐答案</ strong></h1><br>
<p><p>你还需要告诉它在设置cornerRadius之后不要画到它的边界之外。</p>
<pre><code>//this is on the layer level
self.progressView.layer.masksToBounds = true
//another way is to use clipToBounds
self.progressView.clipsToBounds = true
</code></pre></p>
<p style="font-size: 20px;">关于ios - 更改 UIProgressbar 的高度并给出边框和角半径,我们在Stack Overflow上找到一个类似的问题:
<a href="https://stackoverflow.com/questions/44860309/" rel="noreferrer noopener nofollow" style="color: red;">
https://stackoverflow.com/questions/44860309/
</a>
</p>
页:
[1]