Add watermarks to your photos on iOS

Source: Internet
Author: User

In the project we need to mark the photos taken to prevent the image from being stolen, so this need to add a watermark on the photo, to indicate that the photo is unique.

Watermark is not to add a few labels on the top, but we have to take pictures to the picture as a whole.

Provide a method this method only needs to pass a watermark image and watermark content to achieve the effect

1-(UIImage *) Watermarkimage: (UIImage *) img withname: (NSString *) name2 3 {4 5nsstring* Mark =name;6 7     intW =Img.size.width;8 9     inth =Img.size.height;Ten  One Uigraphicsbeginimagecontext (img.size); A  -[img Drawinrect:cgrectmake (0,0, W, h)]; -  theNsdictionary *attr = @{ -  -Nsfontattributename: [Uifont boldsystemfontofsize: -],//Set Font -  +Nsforegroundcolorattributename: [Uicolor Redcolor]//Set Font Color -  +                            }; A  at[Mark Drawinrect:cgrectmake (0,Ten, the, +) withattributes:attr]; //upper left corner  -  -[Mark Drawinrect:cgrectmake (W- the,Ten, the, +) withattributes:attr]; //upper right corner  -  -[Mark Drawinrect:cgrectmake (W- the, H- +-Ten, the, +) withattributes:attr]; //Lower right corner  -  in[Mark Drawinrect:cgrectmake (0, H- +-Ten, the, +) withattributes:attr]; //lower left corner  -  toUIImage *aimg =Uigraphicsgetimagefromcurrentimagecontext (); +  - Uigraphicsendimagecontext (); the  *     returnaimg; $ Panax Notoginseng}

Add watermarks to your photos on iOS

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.