title: iPhone: how to draw text in a window?
body: <p>Strange situation - examples from apple works, but after i change them a bit, text is not displayed. This bit of code correctly draws blue background but refuses to draw text on it no matter what i do:</p>
  
  <pre><code>#import &lt;UIKit/UIKit.h&gt;
  
  @interface CWnd : UIWindow @end
  @implementation CWnd
  
  - (void) drawRect : (CGRect) i_poRect
  {
    // This is working : windows is blue.
    CGContextRef oContex = UIGraphicsGetCurrentContext();
    CGContextSetRGBFillColor( oContex, 0, 0, 255, 1 );
    CGContextFillRect( oContex, i_poRect );
    // This is not working : not text is displayed.
    CGContextSelectFont( oContex, "Monaco", 10, kCGEncodingFontSpecific );
    CGContextSetRGBStrokeColor( oContex, 255, 0, 0, 1 ); 
    CGContextSetRGBFillColor( oContex, 255, 0, 0, 1 ); 
    CGContextSetTextDrawingMode( oContex, kCGTextFill );
    CGContextSetTextPosition( oContex, 100, 100 );
    CGContextShowText( oContex, "abc", 3 );
  }
  
  @end
  
  @interface CDelegate : NSObject &lt;UIApplicationDelegate&gt; @end
  @implementation CDelegate
  
  - (void)applicationDidFinishLaunching : (UIApplication *) i_poApp
  {
    CGRect oRect = [ [ UIScreen mainScreen ] bounds ];
      [ [ [ CWnd alloc] initWithFrame : oRect ] makeKeyAndVisible ];
  }
  
  @end
  
  int main(int argc, char *argv[])
  {    
    return UIApplicationMain( argc, argv, nil, @"CDelegate" );
  }
  </code></pre>