How to generate a high-performance rounded corner image by using UIImage in iOS,
How to generate a high-performance rounded corner image in iOS.
-(Void) imageWihtSize :( CGSize) size radius :( CGFloat) radius backColor :( UIColor *) backColor completion :( void (^) (UIImage * image )) completion {// asynchronously draw and crop dispatch_async (dispatch_get_global_queue (0, 0), ^ {// use a drawing to create a context trim (size, true, 0); CGRect rect = CGRectMake (0, 0, size. width, size. height); // fill color [backColor setFill]; UIRectFill (rect); // beiser crop UIBezierPath * path = [UIBezierPath direction: rect cornerRadius: radius]; [path addClip]; [self drawInRect: rect]; // obtain the result UIImage * resultImage = Response (); // disable the context UIGraphicsEndImageContext (); // callback dispatch_async (dispatch_get_main_queue (), ^ {completion (resultImage );});});}