我只需要为从数据库中获取的UIImage添加绿色文本,它是如何完成的?以下是我到目前为止所缺少的内容:
UIImage *img=[UIImage imageWithData:data];
UIGraphicsBeginImageContext(CGSizeMake(360, 270));
CGImageRef imageCon=[img CGImage];
CGContextRef context = UIGraphicsGetCurrentContext();
CGContextSelectFont(context, "Helvetica", 12, NSMacOSRomanStringEncoding);
CGContextSetTextDrawingMode(context, kCGTextFill);
CGContextSetFillColor(context, CGColorGetComponents([[UIColor whiteColor] CGColor]));
CGAffineTransform xform = CGAffineTransformMake( 1.0, 0.0, 0.0, -1.0, 0.0, 0.0);
CGContextSetTextMatrix(context, xform);
CGContextShowTextAtPoint(context, 100.0f, 180.0f, "test", strlen("test"));
UIImage *imgToAdd=[UIImage imageWithCGImage:CGBitmapContextCreateImage(context)];
[arr addObject:imgToAdd];