Get context, the previous context is obtained in the view's DrawRect method (context layer context associated with view)
Currently we need to draw the picture to the new picture, so we need to use the bitmap context
How to get the bitmap context, note that the bitmap context is not obtained in the same way as the layer. The bitmap context requires that we create it manually.
Opens a bitmap context, noting that the bitmap context is not associated with view, so it does not need to be drawrect.
-(void) Viewdidload {
[Super Viewdidload];
Loading pictures
UIImage *image = [UIImage imagenamed:@ "small yellow Man"];
Size: The dimensions of the bitmap context (the size of the new picture)
Opaque: Opacity YES: Opaque No: Transparent, usually we are generally transparent context
Scale: Typically no scaling context is required, with a value of 0 indicating no scaling
0. Creating a Bitmap context
Uigraphicsbeginimagecontextwithoptions (image.size, NO, 0);
1. Draw the native picture
[Image Drawatpoint:cgpointzero];
2. Add text to the native image
NSString *str = @ "Small size elder brother";
Create Dictionary Properties
Nsmutabledictionary *dict = [Nsmutabledictionary dictionary];
Dict[nsforegroundcolorattributename] = [Uicolor redcolor];
Dict[nsfontattributename] = [Uifont systemfontofsize:20];
[Str drawatpoint:cgpointmake (528) withattributes:dict];
3. Generate a picture for us, get the picture from the context
UIImage *imagewater = Uigraphicsgetimagefromcurrentimagecontext ();
4. Close the context
Uigraphicsendimagecontext ();
_imageview.image = Imagewater;
}
The making of image watermark in iOS