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
UIBezierPath *myClippingPath = ... | |
CAShapeLayer *mask = [CAShapeLayer layer]; | |
mask.path = myClippingPath.CGPath; | |
myView.layer.mask = mask; |
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
UIToolbar *blurringToolbar = [[UIToolbar alloc] initWithFrame:self.someView.bounds]; | |
blurringToolbar.barStyle = UIBarStyleDefault; | |
blurringToolbar.translucent = YES; | |
blurringToolbar.autoresizingMask = UIViewAutoresizingFlexibleHeight | UIViewAutoresizingFlexibleWidth; | |
[self.someView insertSubview:blurringToolbar atIndex:0]; |
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
CGSize imageSize = [[UIApplication sharedApplication] keyWindow].bounds.size; | |
UIGraphicsBeginImageContextWithOptions(imageSize, NO, [[UIScreen mainScreen] scale]); | |
[[[UIApplication sharedApplication] keyWindow] drawViewHierarchyInRect:[[UIApplication sharedApplication] keyWindow].bounds afterScreenUpdates:YES]; | |
UIImage *viewImage = UIGraphicsGetImageFromCurrentImageContext(); | |
UIGraphicsEndImageContext(); | |
return viewImage; |
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 *) screenshot | |
{ | |
// Create a graphics context with the target size | |
// On iOS 4 and later, use UIGraphicsBeginImageContextWithOptions to take the scale into consideration | |
// On iOS prior to 4, fall back to use UIGraphicsBeginImageContext | |
CGSize imageSize = [[UIScreen mainScreen] bounds].size; | |
if (NULL != UIGraphicsBeginImageContextWithOptions) | |
UIGraphicsBeginImageContextWithOptions(imageSize, NO, 0.0); | |
else | |
UIGraphicsBeginImageContext(imageSize); |
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 *)blurImage:(UIImage *)image withStrength:(float)strength | |
{ | |
CIContext *context = [CIContext contextWithOptions:nil]; | |
CIImage *inputImage = [[CIImage alloc] initWithCGImage:image.CGImage]; | |
CIFilter *filter = [CIFilter filterWithName:@"CIGaussianBlur"]; | |
[filter setValue:inputImage forKey:@"inputImage"]; | |
[filter setValue:[NSNumber numberWithFloat:strength] forKey:@"inputRadius"]; | |
CIImage *result = [filter valueForKey:kCIOutputImageKey]; | |
float scale = [[UIScreen mainScreen] scale]; |