ios - Category on UIImage to return a blank UIImage? -
how create uiimage context can return it? want have transparent pixels. have different method adds smaller uiimages larger one, need blank slate begin with.
+ (uiimage *)blankuiimageofsize:(cgsize)size { uigraphicsbeginimagecontextwithoptions(size, no, 1); ...? }
the following should work:
+ (uiimage *)blankuiimageofsize:(cgsize)size { uigraphicsbeginimagecontextwithoptions(size, no, 1); cgcontextref ctx = uigraphicsgetcurrentcontext(); cgcontextclearrect(ctx, cgrectmake(0, 0, area.width, area.height)); uiimage *newimage = uigraphicsgetimagefromcurrentimagecontext(); uigraphicsendimagecontext(); return newimage; }
Comments
Post a Comment