Tôi cần vẽ một hình lục giác và tô màu nó bằng một bản dựng màu với hình ảnh làm mẫu. tôi đã làm:Đường dẫn FillPath và đường nét Stroke
CGContextSaveGState(context);
CGContextSetLineCap(context, kCGLineCapRound);
CGContextSetFillColorWithColor(context, [[UIColor colorWithPatternImage:[UIImage imageNamed:@"patternerba.png"]] CGColor]);
CGContextSetStrokeColorWithColor(context, [[UIColor blackColor] CGColor]);
CGContextSetLineWidth(context, 3.0);
// drawing hexagon here...
CGContextStrokePath(context);
CGContextFillPath(context);
[[NSString stringWithFormat:@"Foo"] drawAtPoint:innerRect.origin withFont:[UIFont fontWithName:@"Helvetica" size:16]];
CGContextRestoreGState(context);
Nhưng tùy thuộc từ thứ tự của CGContextStrokePath và CGContextFillPath, tôi nhận được một hình lục giác giáp nhưng không điền hoặc điền nhưng không giáp. Làm thế nào tôi có thể sửa lỗi này?
tăng chiều rộng trong CGContextSetLineWidth .. –