Created
July 19, 2011 20:24
-
-
Save AtomicCat/1093617 to your computer and use it in GitHub Desktop.
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
| dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_HIGH, 0), ^(void) | |
| { | |
| // take snapshot of main view to fake background | |
| // | |
| // start with a vertical slice of the middle, slightly taller than modal | |
| // | |
| // translate & clip layer before rendering for performance | |
| // | |
| CGContextRef c = CGBitmapCreateSomethingSomething(args); | |
| CGContextTranslateCTM(c, (baseView.bounds.size.width - 540) / -2, 0); | |
| CGContextClipToRect(c, CGRectMake((baseView.bounds.size.width - 540) / 2, 0, 540, baseView.bounds.size.height - ((baseView.bounds.size.height - 620) / 2))); | |
| // render to context | |
| // | |
| [baseView.layer renderInContext:UIGraphicsGetCurrentContext()]; | |
| CGImageRef imageRef = CGBitmapCreateImagePlease(c); | |
| CGContextRelease(c); | |
| // set image from it | |
| // | |
| dispatch_saync(dispatch_get_main_queue(), ^(void) | |
| { | |
| backgroundImageView.image = [UIImage imageWithCGImage:imageRef]; | |
| CGImageRelease(imageRef); | |
| ); | |
| }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment