BarCharView修改bar圆角

2022-05-17  本文已影响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)

上一篇 下一篇

猜你喜欢

热点阅读