- Create a UIImage object
- UIImage *image = [UIImage imagenamed:@ "scene1.jpg"];
- 1. Establish Bitmap Context
- Uigraphicsbeginimagecontext (image.size);
- 2. Draw the original image to the context
- [Image drawinrect:cgrectmake (0, 0, Image.size.width, image.size.height)];
- 3. Draw the watermark text to the context.
- Watermark in lower left corner
- CGRect textFrame = CGRectMake (0, image.size.height-40, 200, 40);
- Set Watermark Text Properties
- Uifont *font = [Uifont boldsystemfontofsize:30];
- Nsmutableparagraphstyle *style = [[Nsmutableparagraphstyle alloc] init];
- Style.alignment = Nstextalignmentcenter;
- Uicolor *color = [Uicolor colorwithred:254.0/255 green:201.0/255 blue:21.0/255 alpha:1];
- [Text Drawinrect:textframe withattributes:
- @{nsfontattributename:font,
- Nsforegroundcolorattributename:color,
- Nsparagraphstyleattributename:style}];
- 4. From the bitmap context to obtain a watermark after the picture.
- UIImage *waterimage = Uigraphicsgetimagefromcurrentimagecontext ();
- 5. Close Bitmap context.
- Uigraphicsendimagecontext ();
- 6. Return the captured picture
- return waterimage;
- This method is best to be independent of a single class, which can be done with just one type of method.
Image add watermark Effect