我正在使用这段代码在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)
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。