How to create a new image from an existing image and a string over it
I need to create something like: http://t3.gstatic开发者_如何学运维.com/images?q=tbn:ANd9GcQZu06WspVUaFTn-C-YD6Pzu_oWH5NLA1Q8nPUZEdemllFIAMNn
So I need to place a user input string over an image in a specified spot, then save it in the memory.
How can I do it?
- Create a new bitmap image context. See this for help creating-and-drawing-on-a-new-uiimage
- Draw your UIImage in
drawInRect
- Create black, rounded and transparent image. See this for help: resize-a-uiimage-the-right-way
- Draw black image
drawInRect
- Draw your NSString text. see this for help how-to-display-text-using-quartz-on-the-iphone
drawInRect
ordrawInPoint
Here is a small code example for cropping an image.
- (UIImage *)croppedImageWithRect:(CGRect)bounds {
CGImageRef imageRef = CGImageCreateWithImageInRect(scaleImage.CGImage, bounds);
UIImage *croppedImage = [UIImage imageWithCGImage:imageRef];
CGImageRelease(imageRef);
return croppedImage;
}
Enjoy.
use a UItextView over an image to show such string.
精彩评论