【发布时间】:2021-07-04 00:07:27
【问题描述】:
我正在尝试具有动态数据的PieChart。
在点击每个Pie时,它必须突出显示并且处于正常状态。
动态更改lineWidth 的CAShapeLayer,但lineWidth 从中间路径增加。
它必须从下到上增加
代码:
let centerPoint = CGPoint (x: circle.bounds.width / 2, y: circle.bounds.width / 2)
let circleRadius : CGFloat = circle.bounds.width / 2 * 0.83
let circlePath = UIBezierPath(arcCenter: centerPoint, radius: circleRadius, startAngle: CGFloat(1.0 * .pi), endAngle: CGFloat(3.0 * .pi), clockwise: true)
let progressCircle = CAShapeLayer()
progressCircle.path = circlePath.cgPath
progressCircle.strokeColor = color.cgColor
progressCircle.fillColor = UIColor.clear.cgColor
if onClick == 2 {
progressCircle.lineWidth = 60
} else {
progressCircle.lineWidth = 30
}
progressCircle.strokeStart = strokeStart/PieChartConstant.maxPercent
progressCircle.lineCap = CAShapeLayerLineCap.butt
progressCircle.strokeEnd = strokeEnd/PieChartConstant.maxPercent
查询:
增加的Pie 应该和之前的Pies 一样。请指导我,如何实现这一目标。
推荐人:
Checked_this,但无法实现,也不知道如何实现。
我的输出:
【问题讨论】:
-
有什么问题?
-
嗨@matt 增加的派应该和以前的派一样。 .,如何实现?
-
我不知道你所说的“相同的轨道”是什么意思。你能展示一张你希望它们看起来如何的图片吗?
-
@Sweeper 图像已更新。突出显示的饼图应与“必需”图像位于同一路径
-
看起来,所需图像中的所有线宽都相同。为什么您首先有条件地将
lineWidth设置为不同的值?您应该将所有线宽设置为相同的数字。
标签: ios swift uiview pie-chart cashapelayer