title: Add text to CALayer : drawInRect not working
body: <p>I did the following : </p>
  
  <pre><code>- (void)drawLayer:(CALayer *)layer inContext:(CGContextRef)ctx
  {
  
        UIGraphicsPushContext ( ctx );
  
        CGRect r = CGRectMake( 500, 300, 200, 100 );
        NSString *text = [[NSString alloc] initWithString:@"raaaaaaaa!"];
        UIColor *color = [ UIColor colorWithRed: (200.0f)  green: (100.0)  blue:(200.0f) alpha: 1.0f ];
        [color set];
  
        [ text drawInRect: r withFont:[UIFont systemFontOfSize:50] lineBreakMode: UILineBreakModeWordWrap alignment: UITextAlignmentLeft ];
        [text release];
  
        UIGraphicsPopContext();
      }
    }
  }
  </code></pre>
  
  <p>The above code is not working.  Why?</p>
  
  <p>If i do the following instead, it is working:</p>
  
  <pre><code>- (void)drawLayer:(CALayer *)layer inContext:(CGContextRef)ctx
  {
        UIGraphicsPushContext ( ctx );
  
        CATextLayer *label = [[CATextLayer alloc] init];
        [label setFont:@"Didot"];
        [label setFontSize:50];  
        [label setFrame:CGRectMake( 400, 300, 400, 100 )];
        [label setString:@"Helloooooooooooooooooo"];
        [label setAlignmentMode:kCAAlignmentCenter];
        [label setForegroundColor:[[UIColor blueColor] CGColor]];
        [layer addSublayer:label];
        [label release];
  
        UIGraphicsPopContext();
    }
  }
  </code></pre>
  
  <p>What is the difference and why drawInRect does nothing?</p>
  
  <p>Thank you</p>
  
  <p><strong>EDIT</strong>
  So, I was not using UIColor properly, so I changed</p>
  
  <pre><code>UIColor *color = [ UIColor colorWithRed: (200.0f)  green: (100.0)  blue:(200.0f) alpha: 1.0f ];
  </code></pre>
  
  <p>for this</p>
  
  <pre><code>UIColor *color = [UIColor colorWithRed:200 / 255.0 green:100 / 255.0 blue: 200 / 255.0 alpha: 1.0];
  </code></pre>
  
  <p>Still no luck, I can't see any text when using drawInRect</p>