iOS image plus watermark effect and save to albums

Source: Internet
Author: User

Image plus watermark effect and save to the album
Achieve results

Project download: Githubproject download link

Code:

- (void) Viewdidload {[SuperViewdidload];UIImage*image = [UIImageimagenamed:@"Pushu.jpg"];UIImage*waterimage = [ SelfWatermarkimage:image withtext:@"Park Tree watermark Test"]; Uiimagewritetosavedphotosalbum (Waterimage,Nil,Nil,Nil);//Save pictures to albums//Show Pictures    Uiimageview*imageview = [[UiimageviewAlloc] initWithFrame: Self. View. Bounds]; ImageView. Image= Waterimage; [ Self. ViewAddsubview:imageview];additional setup after loading the view, typically from a nib.}
-(UIImage*)Watermarkimage: (UIImage*)ImageWithtext: (nsstring*)text{Uigraphicsbeginimagecontext (Image.size);//Draw content in the canvas[ImageDrawinrect:cgrectmake (0,0,Image.size. width,Image.size. height)];//Draw text[[Uicolor Darkgraycolor] set]; CGRect rect = CGRectMake ( -, -, $, -); Nsdictionary*dic= @{nsfontattributename:[uifont Systemfontofsize: -], Nsobliquenessattributename:@1};//Here Set the font, and tilt. Specific article links at the end of other reference articles[textDrawinrect:rect Withattributes:dic];//Before iOS7, it is more convenient to use the following methods//[text Drawinrect:rect withfont:[uifont systemfontofsize:30] linebreakmode:nslinebreakbywordwrapping alignment : Nstextalignmentcenter];//Get an image from the canvasUIImage*returnimage= Uigraphicsgetimagefromcurrentimagecontext (); Uigraphicsendimagecontext ();returnReturnimage;}
- (void)drawInRect:(CGRect)rect withAttributes:(NSDictionary *)attrs NS_AVAILABLE_IOS(7_0);

About this method, which is applied after iOS7. Attrs the specific instructions for setting the parameters in the following link article:
Description Article Link: attrs reference article

iOS image plus watermark effect and save to albums

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.