ios - 在 FXBlurView 的单独类中获取 UIView

标签 ios objective-c uiview superview

我正在使用 FXBlurView但是在向下设置 blurView 动画时,我在顶部收到一条奇怪的黑线。

我有一个 UITable 位于 ViewController 的 3/4 处,其余部分是图像。发生了什么事是它只在 super View 中获取 UITable 而不是图像。那么有没有办法让 superview 同时获取两者?还是替代品?

enter image description here

我读到这可以通过用实际的 UIView 替换 superview 来解决

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.

FXBlurView.m代码是:

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

我试过这个:

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

但这没什么区别

ImagesTableViewController 是我的主要 ViewController,其中包含 Blured Uiview 和我要复制的那个 (main_view)

但这只是为 Blured Uiview 创建了一个白页。

最佳答案

首先,您根本不需要编辑 FXBlurView 源。

其次,我猜黑条是未被拾取的 View 层次结构的一部分。也许是导航栏?您可以尝试将模糊 View 添加到窗口而不是 View ,以便抓取所有内容:

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

如果失败,我能想到的唯一破解方法是制作一个使用窗口抓取其图像的 imageView,如:

- (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;
}

与:

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

然后将 imageView.image 设置为抓取的图像并将其设置为底层 View 。不过你不需要这样做:)

否则我需要查看更多代码才能理解 View 层次结构。

关于ios - 在 FXBlurView 的单独类中获取 UIView,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24542076/

相关文章:

ios - 使用照片框架按图片大小过滤照片库

ios - 如何从 rac_sequence、reactive cocoa、ios 获取项目

ios - swift 3 layoutIfneeded 无法正常工作

ios - 旋转后如何获取superview的frame?

html - <pre> 标签的 NSAttributedString 转换等价物是什么?

ios - 使用 Xcode URL 类型

ios - 如何使用 NSPredicate

ios - UITapGestureRecognizer 未被调用

ios - 我真的应该在 Swift 中的什么地方添加和删除通知观察者?

objective-c - Cocoa 应用程序的跳转栏(类似于 XCode 的)控件