美文网首页
BarCharView修改bar圆角

BarCharView修改bar圆角

作者: 空有回忆 | 来源:发表于2022-05-17 15:06 被阅读0次

BarCharView修改bar圆角

修改BarChartRenderer.swift文件中的,@objc open func drawDataSet(context: CGContext, dataSet: IBarChartDataSet, index: Int)函数

原代码:

          if !isSingleColor

            {

                // Set the color for the currently drawn value. If the index is out of bounds, reuse colors.

                context.setFillColor(dataSet.color(atIndex: j).cgColor)

            }

            context.fill(barRect)

更改圆角代码:

if !isSingleColor

            {

                // Set the color for the currently drawn value. If the index is out of bounds, reuse colors.

                context.setFillColor(dataSet.color(atIndex: j).cgColor)

            }

//            context.fill(barRect)

            let bezierPath =UIBezierPath(roundedRect: barRect,byRoundingCorners: [.topLeft, .topRight],cornerRadii:CGSize(width:4,height:4));

            context.addPath(bezierPath.cgPath)

            context.drawPath(using: .fill)

相关文章

网友评论

      本文标题:BarCharView修改bar圆角

      本文链接:https://www.haomeiwen.com/subject/fwjaurtx.html