use*_*418 25 objective-c uiview ios
我正在使用以下代码绘制一个白色笔划和属性指定的颜色的圆:
- (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);
}
Run Code Online (Sandbox Code Playgroud)
我回来的图像看起来像这样:
我怎样才能删除黑色?
use*_*109 39
将backgroundColor
视图设置为[UIColor clearColor]
.
请注意,创建视图时,只需要设置一次背景颜色.
小智 5
这在Swift 3上对我有用:
self.isOpaque = false
self.backgroundColor = UIColor.clear
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
10659 次 |
最近记录: |