开发者

Custom UIPrintPageRenderer not rendering anything

开发者 https://www.devze.com 2023-03-25 16:13 出处:网络
I\'ve created my own UIPrintPageRenderer subclass and in my overload for DrawContentForPage(), I draw a simple rectangle but nothing is rendering:

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:

  1. Change vContext.SetStrokeColor (new float[] { 1.0f, 0.0f, 0.0f, 1.0f }); to vContext.SetRGBStrokeColor(1.0f, 0.0f, 0.0f, 1.0f);

  2. 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).

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号