Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>You have two options. If you would like to use the imgImage.DrawString method you need to first subclass the ImageView, override the Draw method and call imgImage.DrawString method there.</p> <p>Second option would be to create your own bitmap context and draw there. A good example can be find inside of monotouch.dialog. There is a custom drawn calendar. Here is the code from there.</p> <pre><code>public static UIImage MakeCalendarBadge (UIImage template, string smallText, string bigText) { using (var cs = CGColorSpace.CreateDeviceRGB ()){ using (var context = new CGBitmapContext (IntPtr.Zero, 57, 57, 8, 57*4, cs, CGImageAlphaInfo.PremultipliedLast)){ //context.ScaleCTM (0.5f, -1); context.TranslateCTM (0, 0); context.DrawImage (new RectangleF (0, 0, 57, 57), template.CGImage); context.SetRGBFillColor (1, 1, 1, 1); context.SelectFont ("Helvetica", 10f, CGTextEncoding.MacRoman); // Pretty lame way of measuring strings, as documented: var start = context.TextPosition.X; context.SetTextDrawingMode (CGTextDrawingMode.Invisible); context.ShowText (smallText); var width = context.TextPosition.X - start; var ns = new NSString (smallText); UIFont ff = UIFont.FromName ("Helvetica", 10); context.SetTextDrawingMode (CGTextDrawingMode.Fill); context.ShowTextAtPoint ((57-width)/2, 46, smallText); // The big string context.SelectFont ("Helvetica-Bold", 32, CGTextEncoding.MacRoman); start = context.TextPosition.X; context.SetTextDrawingMode (CGTextDrawingMode.Invisible); context.ShowText (bigText); width = context.TextPosition.X - start; context.SetRGBFillColor (0, 0, 0, 1); context.SetTextDrawingMode (CGTextDrawingMode.Fill); context.ShowTextAtPoint ((57-width)/2, 9, bigText); context.StrokePath (); return UIImage.FromImage (context.ToImage ()); } } } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload