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