I've created my own UIPrintPageRenderer subclass and in my overload for DrawContentForPage(), I draw a simple rectangle but nothing is rendering:
public override void DrawContentForPage (int index, RectangleF contentRect)
{
Context vContext = UIGraphics.GetCurrentContext ();
vContext.SetStrokeColor (new float[] { 1.0f, 0.0f, 0.0f, 1.0f });
vContext.SetLineWidth (10);
vContext.StrokeRect (new RectangleF (PrintableRect.Left + 10, Print开发者_运维知识库ableRect.Top + 10, 100, 100));
}
Why not?
It turns out there are two ways to "fix" this:
Change
vContext.SetStrokeColor (new float[] { 1.0f, 0.0f, 0.0f, 1.0f });
tovContext.SetRGBStrokeColor(1.0f, 0.0f, 0.0f, 1.0f);
Call
vContext.SetStrokeColorSpace (CGColorSpace.CreateDeviceRGB ());
Both of these solutions have the effect of first setting the current stroke color space to RGB before setting the color values. The reason it wasn't working before is because the colorspace was obviously not set to RGB (it was probably CMYK or something).
精彩评论