我的形状有一些UIBezierPaths,我试图在我的视图中绘制它们并没有显示出来。你能告诉我我做错了什么吗?
// Function to perform custom drawing.
- (void)drawRect:(CGRect)rect
{
CGContextRef currentContext = UIGraphicsGetCurrentContext();
for (Stroke* stroke in letter.strokes)
{
if (letter.strokes[letter.currentStroke] == stroke)
{
[stroke.path stroke];
}
else
{
[stroke.path strokeWithBlendMode:kCGBlendModeNormal alpha:0.5f];
}
[self setNeedsDisplayInRect:stroke.path.bounds];
}
}
新代码也无效:
for (Stroke* stroke in letter.strokes)
{
UIBezierPath* path = stroke.path;
[[UIColor blackColor] setStroke];
[[UIColor redColor] setFill];
CGContextRef currentContext = UIGraphicsGetCurrentContext();
CGContextSaveGState(currentContext);
CGContextTranslateCTM(currentContext, 50, 50);
path.lineWidth = 5;
if (letter.strokes[letter.currentStroke] == stroke)
{
[path fill];
[path stroke];
}
else
{
[stroke.path strokeWithBlendMode:kCGBlendModeNormal alpha:0.5f];
}
[self setNeedsDisplayInRect:stroke.path.bounds];
CGContextRestoreGState(currentContext);
}
答案 0 :(得分:0)
我最终通过将此视图和我的另一个视图附加到视图控制器并正确分层来修复它。