[Solved] How do you add a textview to a image view?


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;
}

solved How do you add a textview to a image view?