Last active
October 24, 2015 17:58
-
-
Save rbaulin/d491e349fd0aade48a1b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- (UIImage *)render:(CGRect)frame { | |
if (CGRectIsEmpty(frame) || CGRectIsInfinite(frame) || CGRectIsNull(frame)) { | |
return nil; | |
} | |
UIGraphicsBeginImageContextWithOptions(frame.size, NO, 0); // same as [[UIScreen mainScreen] scale] | |
// drawing code | |
// Create new image | |
UIImage *newImage = UIGraphicsGetImageFromCurrentImageContext(); | |
UIGraphicsEndImageContext(); | |
// newImage = [newImage imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal]; | |
// newImage = [newImage resizableImageWithCapInsets:UIEdgeInsetsMake(r, r, r, r)]; | |
return newImage; | |
} | |
// gist static frame size variant | |
UIImage *<#name#>Image() { | |
CGRect frame = CGRectMake(0, 0, <#width#>, <#height#>); | |
// Create context | |
UIGraphicsBeginImageContextWithOptions(frame.size, NO, 0); | |
// Render | |
// Create new image | |
UIImage *newImage = UIGraphicsGetImageFromCurrentImageContext(); | |
UIGraphicsEndImageContext(); | |
return newImage; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment