【问题标题】:Custom UIPrintPageRenderer not rendering anything自定义 UIPrintPageRenderer 不渲染任何东西
【发布时间】:2011-08-02 22:59:34
【问题描述】:

我创建了自己的 UIPrintPageRenderer 子类,在 DrawContentForPage() 的重载中,我绘制了一个简单的矩形,但没有渲染:

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, PrintableRect.Top + 10, 100, 100));
}

为什么不呢?

【问题讨论】:

    标签: iphone ios mono xamarin.ios


    【解决方案1】:

    事实证明有两种方法可以“解决”这个问题:

    1. vContext.SetStrokeColor (new float[] { 1.0f, 0.0f, 0.0f, 1.0f });更改为vContext.SetRGBStrokeColor(1.0f, 0.0f, 0.0f, 1.0f);

    2. 致电vContext.SetStrokeColorSpace (CGColorSpace.CreateDeviceRGB ());

    这两种解决方案都具有在设置颜色值之前先将当前笔触颜色空间设置为 RGB 的效果。它之前不起作用的原因是因为颜色空间显然没有设置为 RGB(可能是 CMYK 或其他东西)。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2022-11-21
      • 1970-01-01
      • 1970-01-01
      • 2019-03-21
      • 2014-09-08
      • 2017-10-06
      • 2016-10-01
      相关资源
      最近更新 更多