How to draw multiple line text to uiimageview iphone?

Posted by Hu?nh Phong on Stack Overflow See other posts from Stack Overflow or by Hu?nh Phong
Published on 2012-12-08T01:55:36Z Indexed on 2012/12/08 5:04 UTC
Read the original article Hit count: 148

Filed under:
|
|
|

I have UITextView for text, after user press DONE, I convert text to UIImageView and show it. It works with one line of text very good,

and Screenshot 1

. But if user types two lines, or more: the result is still one line??? Screenshot 2

I want to display two or more lines in UIimageView

Can anybody help me! Thank you very much!

Here is my code:

-(UIImage *)convertTextToImage : (ObjectText *) objT; 
{ 
    UIGraphicsBeginImageContext(CGSizeMake(([objT.content sizeWithFont:objT.font].width+10), ([objT.content sizeWithFont:objT.font].height+10)));
    [[objT getcolor] set];
    [objT.content drawAtPoint:CGPointMake(5, 5) withFont:objT.font];
    UIImage *result = UIGraphicsGetImageFromCurrentImageContext();     
    UIGraphicsEndImageContext(); 
    return result; 
}

© Stack Overflow or respective owner

Related posts about iphone

Related posts about text