我有一个正在绘制的形状,drawRect它存储在CGMutablePathRef( shapeMutablePath) 中。每次drawRect调用时,形状都会被拉伸以适应屏幕,并在其周围有一个笔触边框。我想知道,如何在不拉伸的情况下绘制笔触边框?即拉伸shapeMutablePath,然后在它周围绘制描边边框,以便每次绘制时它的宽度都相同?我尝试更改比例的顺序以及添加和绘制路径无济于事。
- (void) drawRect:(CGRect)rect
{
CGContextRef context = UIGraphicsGetCurrentContext();
CGContextSaveGState(context);
CGContextSetRGBFillColor(context, 1.0000, 1.0000, 1.0000, 1.0000);
CGContextSetRGBStrokeColor(context,0.0000,0.0000,0.0000,1.0000);
CGContextSetLineWidth(context, DialogueTextViewLineWidth);
CGContextScaleCTM (context, self.frame.size.width / self.shapeMutablePathWidth, self.frame.size.height / self.shapeMutablePathHeight);
CGContextAddPath(context, self.shapeMutablePath);
CGContextDrawPath(context, kCGPathFillStroke);
CGContextRestoreGState(context);
}