绘图圆没有填写IOS

我正在使用这段代码在UI ImageView中画一个圆.
CAShapeLayer *circleLayer = [CAShapeLayer layer];
// Give the layer the same bounds as your image view
[circleLayer setBounds:CGRectMake(0.0f,0.0f,[photoView bounds].size.width,[photoView bounds].size.height)];
// Position the circle anywhere you like,but this will center it
// In the parent layer,which will be your image view's root layer
[circleLayer setPosition:CGPointMake(coordsFinal.x + 130,coordsFinal.y + 200)];
// Create a circle path.
UIBezierPath *path = [UIBezierPath bezierPathWithovalInRect:
                      CGRectMake(0.0f,50.0f,50.0f)];
// Set the path on the layer
[circleLayer setPath:[path CGPath]];
// Set the stroke color
[circleLayer setstrokeColor:[color CGColor]];
// Set the stroke line width
[circleLayer setlinewidth:2.0f];

// Add the sublayer to the image view's layer tree
[[photoView layer] addSublayer:circleLayer];

我希望圈子是空的,只有边界.如何清除填充?

解决方法

将填充颜色设置为透明(alpha 0)
[circleLayer setFillColor:[[UIColor colorWithWhite:0 alpha:0] CGColor]];

AKA …

[circleLayer setFillColor:[[UIColor clearColor] CGColor]];

(谢谢Zev)

相关文章

UITabBarController 是 iOS 中用于管理和显示选项卡界面的一...
UITableView的重用机制避免了频繁创建和销毁单元格的开销,使...
Objective-C中,类的实例变量(instance variables)和属性(...
从内存管理的角度来看,block可以作为方法的传入参数是因为b...
WKWebView 是 iOS 开发中用于显示网页内容的组件,它是在 iO...
OC中常用的多线程编程技术: 1. NSThread NSThread是Objecti...