nicklockwood / FXBlurView

[DEPRECATED]
Other
4.94k stars 713 forks source link

FXBlurView has a serious Bug, subview.hidden became false. #126

Open iStarEternal opened 8 years ago

iStarEternal commented 8 years ago

FXBlurView has a serious Bug. When I set subview hidden: view.subviews[1].hidden = true; And add FXBlurView: [view addSubview:[[FXBlurView alloc] initWithFrame:view.bounds]; The subview.hidden will become false.

Example:

I'm using MJRefresh: https://github.com/CoderMJLee/MJRefresh MJRefreshNormalHeader *header = [MJRefreshNormalHeader headerWithRefreshingTarget:self refreshingAction:@selector(refreshHeader:)]; header.lastUpdatedTimeLabel.hidden = true; self.tableView.mj_header = header;

Now, all is all right! But when I add it: FXBlurView *blurView = [[FXBlurView] alloc] initWithFrame:self.view.bounds]; [self.view addSubview:blurView]; And The I remove it. [blurView removeFromSuperView]; self.tableView.mj_header.lastUpdatedTimeLabel.hidden was became false.

I find the was unusual when for (CALayer *layer in superlayer.sublayers) { layer.hidden = false; }

There!

Please forgive me for being impolite, My English is not very good.

iStarEternal commented 8 years ago

If you want to Demo, ask me.

nicklockwood commented 8 years ago

I think the problem is that FXBlurView hides subviews automatically when snapshotting, then re-shows them. I guess it should kee track of which ones were already hidden.

iStarEternal commented 8 years ago

Thank you for your kind reply. I hope you can make it better soon.

HoneyLuka commented 8 years ago

I have same problem. I agree that this is a serious bug.

HoneyLuka commented 8 years ago

@nicklockwood I found this bug.

- (NSArray *)hideEmptyLayers:(CALayer *)layer
{
    NSMutableArray *layers = [NSMutableArray array];
    if (CGRectIsEmpty(layer.bounds)) // **** Bug is here. ****
    {
        layer.hidden = YES;
        [layers addObject:layer];
    }
    for (CALayer *sublayer in layer.sublayers)
    {
        [layers addObjectsFromArray:[self hideEmptyLayers:sublayer]];
    }
    return layers;
}

This line should check if the layer is already hidden:

if (CGRectIsEmpty(layer.bounds))

change to this will resolve problem:

if (CGRectIsEmpty(layer.bounds) && !layer.hidden)
HoneyLuka commented 8 years ago

Can I create a PR for this?

kirian commented 8 years ago

@HoneyLuka sounds a good approach, they use all layers with bounds even the hidden layers in order to render the view. After rendering, they restore the superview unhiding all layers. (even your hidden layers).