getting UIView in separate class for FXBlurView

北城以北 提交于 2019-12-11 11:19:34

问题


I am using FXBlurView but I am receiving a weird black line at the top when animating the blurView down.

I have a UITable that is 3/4 up the ViewController and an image that is the rest. What is happening Is that it is only picking up the UITable and not the image, in the superview. So is there a way to get the superview to pick up both? or a replacement?

I have read that this can be fixed by replacing the superview with the actual UIView

FXBlurView captures the contents of its immediate superview by default. If the superview is transparent or partially transparent, content shown behind it will not be captured. You can override the underlyingView property to capture the contents of a different view if you need to.

The FXBlurView.m code is:

- (UIView *)underlyingView
{
    return _underlyingView ?: self.superview;
}

I have tried this:

((FXBlurView *)self.Genres).underlyingView = _main_view;

but this makes no difference

where ImagesTableViewController is my main ViewController containing the Blured Uiview and the one I want to replicate (main_view)

But this just creates a white page for the Blured Uiview.


回答1:


First off you shouldn't need to edit the FXBlurView source at all.

Secondly I guess the black bar is part of the view hierarchy that isn't getting picked up. Maybe a navbar? You might try adding the blur view to the window rather than the view so you grab everything:

[[[UIApplication sharedApplication] keyWindow] addSubview: blurView];

Failing that the only hack I can think would be to make an imageView that grabs its image using the window like:

- (UIImage *)screenGrab:(id) theView {

   CGRect rect = [self.view bounds];

    UIGraphicsBeginImageContext(rect.size);
    CGContextRef context = UIGraphicsGetCurrentContext();
    [theView.layer renderInContext:context];   
    UIImage *image = UIGraphicsGetImageFromCurrentImageContext();
    UIGraphicsEndImageContext();
    return image;
}

with:

[self screenGrab: [[UIApplication sharedApplication] keyWindow]];

Then set imageView.image to the grabbed image and set this as the underlying view. You shouldn't need to do this though :)

Failing that I'd need to see a bit more code to understand the view hierarchy.



来源:https://stackoverflow.com/questions/24542076/getting-uiview-in-separate-class-for-fxblurview

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!