tags:

views:

77

answers:

1

Hello All,

How to Convert Text to Image and show in UIImageview. Can anyone know the conversion from Text to Image?

+4  A: 

You can start playing around with something like this:

NSString *string = @"Some text";
UIGraphicsBeginImageContext(CGSizeMake(80, 50));
[string drawAtPoint:CGPointMake(10, 20)
           withFont:[UIFont systemFontOfSize:12]];
UIImage *result = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();

result contains the UIImage with the text in it, and you can assign it to the UIImageView image property.

duncanwilcox