i want to get a multiple line string from a UITextView and draw it on a image, the position of text in the image must exactly same as the position in UITextView but i dont want jus add the textView to UIImageView, i need a new image consists of those text, is it possible? any suggestion to do that?
You can capture the contents of any UIView into a UIImage. First, create an empty UIView and position your UIImageView and UITextView as subviews:
// Assumes you have UIImageView *myImageView and UITextField *myTextField
UIView *parentView = [[UIView alloc] initWithFrame:CGRectZero];
[myImageView setFrame:CGRectMake(0, 0, 100, 100)];
[myTextField setFrame:CGRectMake(20, 20, 80, 20)];
Now create a graphics context and draw parentView into it:
[[parentView layer] renderInContext:UIGraphicsGetCurrentContext()];
UIImage *outputImage = UIGraphicsGetImageFromCurrentImageContext();
You now have a UIImage with the contents of your UIImageView and UITextField to display, save, or send over the network.
This was a good solution, thanks.
I would like to add that you need to add
To your imports so the warnings go away.