有人知道如何在MonoMac中填充模式,不幸的是,这段代码没有做任何事情。它甚至没有调用绘制模式。任何帮助都会很棒:D
void DrawPattern (CGContext NewContext)
{
Console.WriteLine("Drawing Pattern?");
NewContext.SetFillColor(new CGColor(1,0,0));
NewContext.FillRect(new RectangleF(0,0,5,5));
}
public void FillPatternPath (CGContext MyCanvas,CGPath Path)
{
MyCanvas.SaveState();
CGPath NewPath=Path.GetCGPath ();
MyCanvas.AddPath (NewPath);
RectangleF PBounds=MyCanvas.GetPathBoundingBox();
MyCanvas.EOClip();
CGColorSpace patternSpace = CGColorSpace.CreatePattern(null);
MyCanvas.SetFillColorSpace(patternSpace);
CGPattern Pat=new CGPattern(PBounds,CGAffineTransform.MakeIdentity(),10,10,CGPatternTiling.ConstantSpacing,true,new CGPattern.DrawPattern(DrawPattern));
MyCanvas.SetFillPattern(Pat,new float[]{1f});
MyCanvas.FillRect (PBounds);
patternSpace.Dispose();
MyCanvas.RestoreState();
}
答案 0 :(得分:0)
我最后通过使用简单的for {}例程在剪裁区域中绘制图案来解决这个问题。我从未设法让CGPattern工作。