开发者

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?


  1. Create a new bitmap image context. See this for help creating-and-drawing-on-a-new-uiimage
  2. Draw your UIImage in drawInRect
  3. Create black, rounded and transparent image. See this for help: resize-a-uiimage-the-right-way
  4. Draw black image drawInRect
  5. Draw your NSString text. see this for help how-to-display-text-using-quartz-on-the-iphone drawInRect or drawInPoint


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜