iphoneiosxamarin.iosuifontcgbitmapcontext

iPhone: Retina Display Writing Font to a UIImage


Objective-C Answers are fine, I am using MonoTouch for reference.

I am writing text on top of a UIImage. Retina displays the font in a choppy way. Looks pixel doubled, which I guess is what's happening. How can I get a crisp Font written to a UIImage?

 //context is a CGBitmapContext

 context.SetFillColor (color.CGColor);
 context.SelectFont (font.Name, font.PointSize, CGTextEncoding.MacRoman);

 context.SetTextDrawingMode (CGTextDrawingMode.Fill);
 context.ShowTextAtPoint (pt.X, pt.Y, text);

enter image description here


Solution

  • when you create image context, you should call the

    UIGraphicsBeginImageContextWithOptions(CGSize size, BOOL opaque, CGFloat scale);
    

    not the regular UIGraphicsBeginImageContext, this will generate a context capable display in Retina display.