7
我正在Xamarin开发,并希望绘制一个简单的圆圈内的文字“CIRCLE”,并在UIImageView中显示该图像。问题在于圆圈和文字显得非常模糊。我读了一些关于子像素的内容,但我不认为这是我的问题。iOS绘制一个简单的图像变成模糊使用Xamarin C#
这里的模糊图像和代码,希望有人有一些想法:)
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, 0, width, height));
var contentString = new NSString (content);
var contentSize = contentString.StringSize (font);
var rect = new RectangleF (0, ((height - contentSize.Height)/2) + 0, width, contentSize.Height);
context.SetFillColorWithColor (UIColor.White.CGColor);
new NSString (content).DrawString (rect, font, UILineBreakMode.WordWrap, UITextAlignment.Center);
var image = UIGraphics.GetImageFromCurrentImageContext();
imageView.Image = image;
像素加倍视网膜是问题,你的建议解决了它。良好的工作,谢谢:) – 2013-04-09 08:54:38