这里不是图形程序员,所以我试图通过这个偶然发现。我正在尝试绘制 9 个实心圆圈,每个圆圈都有不同的颜色,每个圆圈都有一个白色边框。UIView 的框架是 CGRectMake (0,0,60,60)。见附图。
问题是我在每一边的边界上都有“平点”。以下是我的代码(来自 UIView 子类):
- (void)drawRect:(CGRect)rect
{
CGRect borderRect = CGRectMake(0.0, 0.0, 60.0, 60.0);
CGContextRef context = UIGraphicsGetCurrentContext();
CGContextSetRGBStrokeColor(context, 1.0, 1.0, 1.0, 1.0);
CGContextSetRGBFillColor(context, colorRed, colorGreen, colorBlue, 1.0);
CGContextSetLineWidth(context, 2.0);
CGContextFillEllipseInRect (context, borderRect);
CGContextStrokeEllipseInRect(context, borderRect);
CGContextFillPath(context);
}
如果我在 drawRect 中更改为 CGRectMake(0,0,56,56),我只会在顶部和左侧得到平坦的点,而底部和右侧看起来很好。
谁能建议我如何解决这个问题?在我看来,边框正在被 UIView 剪裁,但对此知之甚少,我真的不知道如何修复它。
在此先感谢各位图形专家的建议。