【发布时间】:2014-07-02 05:15:26
【问题描述】:
我正在使用此代码绘制一个带有白色笔划和属性指定颜色的圆圈:
- (void)drawRect:(CGRect)rect {
CGContextRef contextRef = UIGraphicsGetCurrentContext();
CGContextClearRect(contextRef, rect);
// Set the border width
CGContextSetLineWidth(contextRef, 1.5);
// Set the circle fill color to GREEN
CGFloat red, green, blue, alpha;
BOOL didConvert = [_routeColor getRed:&red green:&green blue:&blue alpha:&alpha];
CGContextSetRGBFillColor(contextRef, red, green, blue, 1.0);
// Set the cicle border color to BLUE
CGContextSetRGBStrokeColor(contextRef, 255.0, 255.0, 255.0, 1.0);
// Fill the circle with the fill color
CGContextFillEllipseInRect(contextRef, rect);
// Draw the circle border
CGContextStrokeEllipseInRect(contextRef, rect);
}
我得到的图像是这样的:
如何去除黑色?
【问题讨论】:
-
建议 - 摆脱对
CGContextSetRGBFillColor和CGContextSetRGBStrokeColor的调用。相反,请执行以下操作:[_routeColor setFill]; [[UIColor whiteColor] setStroke];。仅供参考 - 颜色值需要在 0.0 - 1.0 范围内,因此所有 255.0 值都应该是 1.0。
标签: ios objective-c uiview