我正在开发Xamarin,并希望在其中绘制一个带有“CIRCLE”文本的简单圆圈,并在UI
ImageView中显示该图像.问题是圆圈和文字显得非常模糊.我已经阅读了一些有关子像素的内容,但我认为这不是我的问题.
这是模糊的图像和代码,希望有人有一些想法:)
- UIGraphics.BeginImageContext (new SizeF(150,150));
- var context = UIGraphics.GetCurrentContext ();
- var content = "CIRCLE";
- var font = UIFont.SystemFontOfSize (16);
- const float width = 150;
- const float height = 150;
- context.SetFillColorWithColor (UIColor.Red.CGColor);
- context.FillEllipseInRect (new RectangleF (0,width,height));
- var contentString = new NSString (content);
- var contentSize = contentString.StringSize (font);
- var rect = new RectangleF (0,((height - contentSize.Height) / 2) + 0,contentSize.Height);
- context.SetFillColorWithColor (UIColor.White.CGColor);
- new NSString (content).DrawString (rect,font,UILineBreakMode.WordWrap,UITextAlignment.Center);
- var image = UIGraphics.GetImageFromCurrentImageContext ();
- imageView.Image = image;