how to draw a NSString in drawrect of UIView?

Posted by senthilmuthu on Stack Overflow See other posts from Stack Overflow or by senthilmuthu
Published on 2010-03-29T10:07:50Z Indexed on 2010/03/29 10:13 UTC
Read the original article Hit count: 828

Filed under:
|

hi, the Newline character is not working in draw rect of UIView? can anyone help?

 - (void)drawRect:(CGRect)rect
{

CGContextRef context = UIGraphicsGetCurrentContext();
UIFont * f = [UIFont systemFontOfSize:20];
[[UIColor darkGrayColor] set];
 CGRect b = [self bounds];

NSString * text = @"hi \nr u";

CGSize sz = CGSizeMake(150,200);

CGContextScaleCTM(context, b.size.width/sz.width, b.size.height/sz.height);
[text drawAtPoint:CGPointMake(0,0) withFont:f];

}

© Stack Overflow or respective owner

Related posts about iphone

Related posts about iphone-sdk