File tree Expand file tree Collapse file tree 1 file changed +8
-8
lines changed
Objective-C/TOCropViewController/Categories Expand file tree Collapse file tree 1 file changed +8
-8
lines changed Original file line number Diff line number Diff line change @@ -33,10 +33,13 @@ - (BOOL)hasAlpha
3333
3434- (UIImage *)croppedImageWithFrame : (CGRect)frame angle : (NSInteger )angle circularClip : (BOOL )circular
3535{
36- UIImage *croppedImage = nil ;
37- UIGraphicsBeginImageContextWithOptions (frame.size , !self.hasAlpha && !circular, self.scale );
38- {
39- CGContextRef context = UIGraphicsGetCurrentContext ();
36+ UIGraphicsImageRendererFormat *format = [UIGraphicsImageRendererFormat new ];
37+ format.opaque = !self.hasAlpha && !circular;
38+ format.scale = self.scale ;
39+
40+ UIGraphicsImageRenderer *renderer = [[UIGraphicsImageRenderer alloc ] initWithSize: frame.size format: format];
41+ UIImage *croppedImage = [renderer imageWithActions: ^(UIGraphicsImageRendererContext *rendererContext) {
42+ CGContextRef context = rendererContext.CGContext ;
4043
4144 // If we're capturing a circular image, set the clip mask first
4245 if (circular) {
@@ -68,10 +71,7 @@ - (UIImage *)croppedImageWithFrame:(CGRect)frame angle:(NSInteger)angle circular
6871 // We do not need to worry about specifying the size here since we're already
6972 // constrained by the context image size
7073 [self drawAtPoint: CGPointZero];
71-
72- croppedImage = UIGraphicsGetImageFromCurrentImageContext ();
73- }
74- UIGraphicsEndImageContext ();
74+ }];
7575
7676 // Re-apply the retina scale we originally had
7777 return [UIImage imageWithCGImage: croppedImage.CGImage scale: self .scale orientation: UIImageOrientationUp];
You can’t perform that action at this time.
0 commit comments