-4

I've been researching this question but the answer I found does not work.

[myImageView addSubview:myTextView];

I want the text to become part of the image, so if I saved myImageView to the camera roll, the text would be included. Am I doing something wrong or is there another way to do this?

pnuts
  • 58,317
  • 11
  • 87
  • 139
  • 1
    Check this. http://stackoverflow.com/a/13522413/1730272. This is what you are looking for – iDev Nov 28 '12 at 00:35

1 Answers1

1

Suppose you've already got a UIImage img, then use the following code to add texts

-(void)drawText:(NSString *)text onImage:(UIImage *)img
{
   UIFont *font = yourTextViewFont;
   UIGraphicsBeginImageContext(img.size);
   [img drawAtPoint:CGPointZero];
   CGContextSetRGBFillColor(UIGraphicsGetCurrentContext(), 1.0, 1.0, 1.0, 1);
   [text drawAtPoint: CGPointMake(20, 20) withFont: font];

   UIImage *ret = UIGraphicsGetImageFromCurrentImageContext();
   UIGraphicsEndImageContext();

   return ret;
}
meim
  • 740
  • 4
  • 7