Charts: 饼图无法将孔颜色设置为nil

创建于 2016-01-03  ·  6评论  ·  资料来源: danielgindi/Charts

对于透明孔,建议:

*Note: Use holeTransparent with holeColor = nil to make the hole transparent.*```

但是,以下设置会导致崩溃:

pieChart.holeTransparent = true
pieChart.holeColor = nil

看一下实现,holeColor被显式地解包了,大概是因为检查了它之前的nil。 但是,显式展开不在检查范围之内:

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))
            }

临时解决方法:

pieChart.holeColor = UIColor.clearColor()

最有用的评论

这是一个语法错误,应为lowerCase if ;-)

所有6条评论

你是对的 :-)
还有一些!期从斯威夫特的初期时,这并不是说清楚有多少不安全的是,挂在! ...
他们中的大多数现在都走了,谢谢上帝!

我想你是说

If let god = god {
    thank(god)
}

期待对其进行测试!

😂

这是一个语法错误,应为lowerCase if ;-)

我需要在饼图(如Holecolor)内包含与特定切片相对应的颜色阴影。 我怎样才能做到这一点?

如何实现标签即时以在饼图中创建图像
迅捷4

此页面是否有帮助?
0 / 5 - 0 等级

相关问题

cilasgimenez picture cilasgimenez  ·  4评论

Aungbandlab picture Aungbandlab  ·  4评论

BrandonShega picture BrandonShega  ·  4评论

deepumukundan picture deepumukundan  ·  3评论

brytnvmg picture brytnvmg  ·  4评论