我已经创建了自己的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));
}为什么不行?
发布于 2011-08-03 07:00:55
事实证明,有两种方法可以“修复”这个问题:
将vContext.SetRGBStrokeColor(1.0f, 0.0f, 0.0f, 1.0f);
vContext.SetStrokeColorSpace (CGColorSpace.CreateDeviceRGB ());的
vContext.SetStrokeColor (new float[] { 1.0f, 0.0f, 0.0f, 1.0f });这两种解决方案的效果都是先将当前笔划颜色空间设置为RGB,然后再设置颜色值。它以前不工作的原因是因为色彩空间显然没有设置为RGB (它可能是CMYK或其他什么)。
https://stackoverflow.com/questions/6919741
复制相似问题