Vin*_*thy 3 uiprogressview swift3
我有一个 UIProgressView 并且希望填充部分(进度部分)有一个圆角半径,我可以使用cornerRadius 属性使进度视图的角变圆,我也希望填充的进度边缘变圆。请在下面找到进度条现在的样子。
我希望红色部分的边缘变圆。
我尝试使用具有圆角边缘的图像设置progressImage,虽然它解决了这个问题,但图像本身被拉伸得很远,角落的半径没有得到保持。
我尝试的另一件事是绘制一个矩形并用进度颜色填充它,然后使用以下代码将其转换为 UIImage 并将其设置为进度图像,在这种情况下,图像始终为黑色,不确定我缺少什么. 请在下面找到将 uiview 转换为 uiimage 的代码
class func imageWithView(view: UIView) -> UIImage {
UIGraphicsBeginImageContextWithOptions(view.bounds.size, view.isOpaque, 0.0)
view.drawHierarchy(in: view.bounds, afterScreenUpdates: true)
let img = UIGraphicsGetImageFromCurrentImageContext()
UIGraphicsEndImageContext()
return img!
}
Run Code Online (Sandbox Code Playgroud)
小智 7
我使用此代码填充要四舍五入的进度边缘。
myProgressView.layer.sublayers![1].cornerRadius = 12
myProgressView.subviews[1].clipsToBounds = true
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2893 次 |
| 最近记录: |