Created
May 30, 2014 15:42
-
-
Save elfenlaid/25ac54784cd349ca455a to your computer and use it in GitHub Desktop.
Simple copypaste became the reason of interesting debug story :)
This file contains hidden or 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 *)generatedBackground { | |
static NSArray *colors = nil; | |
if (!colors) { | |
colors = @[ | |
[UIColor colorWithRed:0.957 green:0.138 blue:0.287 alpha:1.000], | |
... | |
[UIColor colorWithRed:0.972 green:0.207 blue:0.225 alpha:1.000], | |
]; | |
} | |
UIImage *overlay = [UIImage imageNamed:@"backgroundRoundOverlay"]; | |
UIImage *heavyOverlay = [UIImage imageNamed:@"heavyBackgroundOverlay"]; | |
UIImage *image = nil; | |
UIGraphicsBeginImageContextWithOptions(overlay.size, YES, .0); | |
{ | |
[colors[arc4random() % colors.count] setFill]; | |
[[UIBezierPath bezierPathWithRect:(CGRect) {CGPointZero, overlay.size}] fill]; | |
[overlay drawAtPoint:CGPointZero]; | |
[heavyOverlay drawAtPoint:CGPointZero blendMode:kCGBlendModeNormal alpha:.3]; | |
image = UIGraphicsGetImageFromCurrentImageContext(); | |
} | |
UIGraphicsGetImageFromCurrentImageContext(); // <<- ooops, UIGraphicsEndImageContext intendent call | |
return image; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment