Add Text to the Image

烂漫一生 提交于 2019-12-30 03:33:27

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!