我在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);
如何为此添加黑色边框?
答案 0 :(得分:1)
确保您有上下文:
CGContextRef context = UIGraphicsGetCurrentContext();
然后:
aColor = [UIColor blackColor];
[aColor setStroke];
CGContextSetLineWidth(context, 2.0f);
CGContextAddPath(context, pathRef);
CGContextStrokePath(context);