Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes bug on hideEmptyLayers and on snapshotOfUnderlyingView methods #138

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 4 additions & 6 deletions FXBlurView/FXBlurView.m
Original file line number Diff line number Diff line change
Expand Up @@ -125,8 +125,7 @@ - (UIImage *)blurredImageWithRadius:(CGFloat)radius iterations:(NSUInteger)itera
//apply tint
if (tintColor && CGColorGetAlpha(tintColor.CGColor) > 0.0f)
{
CGContextSetFillColorWithColor(ctx, [tintColor colorWithAlphaComponent:0.25].CGColor);
CGContextSetBlendMode(ctx, kCGBlendModePlusLighter);
CGContextSetFillColorWithColor(ctx, tintColor.CGColor);
CGContextFillRect(ctx, CGRectMake(0, 0, buffer1.width, buffer1.height));
}

Expand Down Expand Up @@ -576,7 +575,7 @@ - (void)displayLayer:(__unused CALayer *)layer

- (UIImage *)snapshotOfUnderlyingView
{
__strong FXBlurLayer *blurLayer = [self blurPresentationLayer];
__strong FXBlurLayer *blurLayer = [self blurLayer];
__strong CALayer *underlyingLayer = [self underlyingLayer];
CGRect bounds = [blurLayer convertRect:blurLayer.bounds toLayer:underlyingLayer];

Expand Down Expand Up @@ -630,7 +629,7 @@ - (UIImage *)snapshotOfUnderlyingView
- (NSArray *)hideEmptyLayers:(CALayer *)layer
{
NSMutableArray *layers = [NSMutableArray array];
if (CGRectIsEmpty(layer.bounds))
if (CGRectIsEmpty(layer.bounds) && !layer.hidden)
{
layer.hidden = YES;
[layers addObject:layer];
Expand Down Expand Up @@ -701,9 +700,8 @@ - (void)updateAsynchronously:(BOOL)async completion:(void (^)())completion
{
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{

UIImage *blurredImage = [self blurredSnapshot:snapshot radius:self.blurRadius];
dispatch_sync(dispatch_get_main_queue(), ^{

UIImage *blurredImage = [self blurredSnapshot:snapshot radius:self.blurRadius];
[self setLayerContents:blurredImage];
if (completion) completion();
});
Expand Down