iPhone: Create image from NSString with word wrap
i am using following function for convert nsstring to image. 

    -(UIImage *)imageFromText:(NSString *)text FontName:(UIFont *)font
    {
        // set the font type and size
        //UIFont *font = [UIFont systemFontOfSize:20.0];  
        CGSize size  = [text sizeWithFont:font];
    	
        UIGraphicsBeginImageContext(size);
    	
        [text drawAtPoint:CGPointMake(0.0, 0.0) withFont:font];
    	
        // transfer image
    	CGContextSetShouldAntialias(UIGraphicsGetCurrentContext(), YES);
    	CGContextSetAllowsAntialiasing(UIGraphicsGetCurrentContext(), YES);
    	
        UIImage *image = UIGraphicsGetImageFromCurrentImageContext();
        UIGraphicsEndImageContext();    
    	
        return image;
    }


Its works well. Problem is that when string contains long text , then it create a image for which width is too much. I want to apply word wrap functionality if text beyond the range.

So how can i create a image with word wrap of NSString. Please suggest
iPhone: Create image from NSString with word wrap
===

i am using following function for convert nsstring to image. 

    -(UIImage *)imageFromText:(NSString *)text FontName:(UIFont *)font
    {
        // set the font type and size
        //UIFont *font = [UIFont systemFontOfSize:20.0];  
        CGSize size  = [text sizeWithFont:font];
    	
        UIGraphicsBeginImageContext(size);
    	
        [text drawAtPoint:CGPointMake(0.0, 0.0) withFont:font];
    	
        // transfer image
    	CGContextSetShouldAntialias(UIGraphicsGetCurrentContext(), YES);
    	CGContextSetAllowsAntialiasing(UIGraphicsGetCurrentContext(), YES);
    	
        UIImage *image = UIGraphicsGetImageFromCurrentImageContext();
        UIGraphicsEndImageContext();    
    	
        return image;
    }


Its works well. Problem is that when string contains long text , then it create a image for which width is too much. I want to apply word wrap functionality if text beyond the range.

So how can i create a image with word wrap of NSString. Please suggest