我正在画一张桌子。首先绘制背景和列网格线。我使用以下
PrintRectangle
方法为替代行绘制行背景。然后将文本绘制到每列和每行。问题是一旦绘制了行背景,就不会显示文本。如果我不绘制行背景,则显示文本。知道我做错了什么吗?
context = UIGraphics.GetCurrentContext();
context.ScaleCTM(1, -1);
void DrawText(string text, string fontName, int fontSize)
{
using (var font = new CTFont(fontName, fontSize))
{
var attributes = new CTStringAttributes
{
ForegroundColorFromContext = true,
Font = font
};
using (var attributedString = new NSAttributedString(text, attributes))
using (var textLine = new CTLine(attributedString))
{
textLine.Draw(context);
}
}
}
void DrawRect(CGRect rect, UIColor fillColor)
{
using (NSAutoreleasePool _autoReleasePool = new NSAutoreleasePool())
{
var path = new CGPath();
path.AddRect(rect);
context.AddPath(path);
context.SetFillColor(fillColor.CGColor);
context.DrawPath(CGPathDrawingMode.Fill);
}
}