我的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);
如何为此添加黑色边框?
最佳答案
确保您具有上下文:
CGContextRef context = UIGraphicsGetCurrentContext();
接着:
aColor = [UIColor blackColor];
[aColor setStroke];
CGContextSetLineWidth(context, 2.0f);
CGContextAddPath(context, pathRef);
CGContextStrokePath(context);