问题
HI
Im currently developing an application where i have to add the text over the image at any position in the image(not subview) and the output should be the single image file with the original image and the text embedded in it,any help will be appreciable.
eg : water mark on the image
Thanks sivasankar
回答1:
UIImage *myImage = loadUnwatermarkedImage();
NSString *myWatermarkText = @"Watermark";
UIImage *watermarkedImage = nil;
UIGraphicsBeginImageContext(myImage.size);
[myImage drawAtPoint: CGPointZero];
[myWatermarkText drawAtPoint: CGPointMake(10, 10) withFont: [UIFont systemFontOfSize: 12]];
watermarkedImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
Upon completion the watermarkedImage will be an autoreleased watermarked image. loadUnwatermarkedImage() is a fictional function providing an original image.
来源:https://stackoverflow.com/questions/2250057/add-text-to-the-image