For a transparent hole, it is recommended to:
*Note: Use holeTransparent with holeColor = nil to make the hole transparent.*```
However, the following set up causes a crash:
pieChart.holeTransparent = true
pieChart.holeColor = nil
Looking at the implementation, the holeColor is explicitly unwrapped, presumably because of the check for nil that precedes it. However, the explicit unwrapping is not in scope of the check:
if (holeColor !== nil && holeColor != UIColor.clearColor())
{
// draw the hole-circle
CGContextSetFillColorWithColor(context, holeColor!.CGColor)
CGContextFillEllipseInRect(context, CGRect(x: center.x - holeRadius, y: center.y - holeRadius, width: holeRadius * 2.0, height: holeRadius * 2.0))
}
// only draw the circle if it can be seen (not covered by the hole)
if (transparentCircleRadiusPercent > holeRadiusPercent)
{
let alpha = holeAlpha * _animator.phaseX * _animator.phaseY
let secondHoleRadius = radius * transparentCircleRadiusPercent
// make transparent
CGContextSetFillColorWithColor(context, holeColor!.colorWithAlphaComponent(alpha).CGColor)
// draw the transparent-circle
CGContextFillEllipseInRect(context, CGRect(x: center.x - secondHoleRadius, y: center.y - secondHoleRadius, width: secondHoleRadius * 2.0, height: secondHoleRadius * 2.0))
}
Temporary workaround:
pieChart.holeColor = UIColor.clearColor()
You are correct :-)
There are still some !
s hanging around from the early days of Swift when it wasn't that clear how much unsafe is that !
...
Most of them are gone now, thank god!
I think you mean
If let god = god {
thank(god)
}
Looking forward to testing it out!
😂
That's a syntax error, should be lowerCase if
;-)
I need to include a color shadow inside piechart( like holecolor) corresponding to a particular slice. how can i do that?
how to implement the label instant to create an image in a pie chart
swift 4
Most helpful comment
That's a syntax error, should be lowerCase
if
;-)