问题描述
- 给CGMutableRefPath添加边框颜色
-
drawRect的代码如下:CGMutablePathRef pathRef = CGPathCreateMutable(); CGPathMoveToPoint(pathRef, NULL, 0, 220); CGPathAddLineToPoint(pathRef, NULL, rect.size.width, 220); CGPathAddLineToPoint(pathRef, NULL, rect.size.width, rect.size.height); CGPathAddLineToPoint(pathRef, NULL, 0, rect.size.height); CGPathCloseSubpath(pathRef);
如何添加黑色的边框和圆角?
解决方案
确保有context:
CGContextRef context = UIGraphicsGetCurrentContext();
然后
aColor = [UIColor blackColor];
[aColor setStroke];
CGContextSetLineWidth(context, 2.0f);
CGContextAddPath(context, pathRef);
CGContextStrokePath(context);
时间: 2024-10-03 17:25:57