Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/objective-c/24.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios 滚动时TableViewCell上的模糊效果_Ios_Objective C_Uitableview_Ios8_Uiimageview - Fatal编程技术网

Ios 滚动时TableViewCell上的模糊效果

Ios 滚动时TableViewCell上的模糊效果,ios,objective-c,uitableview,ios8,uiimageview,Ios,Objective C,Uitableview,Ios8,Uiimageview,现在我正在使用lbbluredimage来模糊图像,但我想改为使用iOS8的UIVisualEffectView来模糊图像 我很难实施,有什么想法吗 使用lbbluredimage实施: - (void)updateData { // Set up Screen self.screenHeight = [UIScreen mainScreen].bounds.size.height; //UIImage *background = [UIImage imageNamed:

现在我正在使用
lbbluredimage
来模糊图像,但我想改为使用
iOS8
UIVisualEffectView
来模糊图像

我很难实施,有什么想法吗

使用
lbbluredimage实施

- (void)updateData {
    // Set up Screen
    self.screenHeight = [UIScreen mainScreen].bounds.size.height;
    //UIImage *background = [UIImage imageNamed:@"gray"];
    UIImage *background = [UIImage imageNamed:backgroundImageGlobal];

    // Background Image
    self.backgroundImageView = [[UIImageView alloc] initWithImage:background];
    self.backgroundImageView.contentMode = UIViewContentModeScaleAspectFill;
    [self.view addSubview:self.backgroundImageView];

    // Background Image Blurred
    self.blurredImageView = [[UIImageView alloc] init];
    self.blurredImageView.contentMode = UIViewContentModeScaleAspectFill;
    self.blurredImageView.alpha = 0.0; // 0.0
    [self.blurredImageView setImageToBlur:background blurRadius:10 completionBlock:nil]; // blurRadius:10
    [self.view addSubview:self.blurredImageView];
}

- (void)scrollViewDidScroll:(UIScrollView *)scrollView {
    CGFloat height = scrollView.bounds.size.height;
    CGFloat position = MAX(scrollView.contentOffset.y, 0.0);
    CGFloat percent = MIN(position / height, 1.0);
    self.blurredImageView.alpha = percent;
}
// iOS8
@property (nonatomic) UIVisualEffect *blurEffect;
@property (nonatomic) UIVisualEffectView *visualEffectView;

// iOS8 Blur
self.blurredImageView = [[UIImageView alloc] init];
self.blurredImageView.contentMode = UIViewContentModeScaleAspectFill;
self.blurredImageView.alpha = 0.0;
UIBlurEffect *blurEffect = [UIBlurEffect effectWithStyle:UIBlurEffectStyleLight];
UIVisualEffectView *visualEffectView = [[UIVisualEffectView alloc] initWithEffect:blurEffect];
visualEffectView.frame = self.blurredImageView.bounds;
[self.blurredImageView addSubview:visualEffectView];
[self.view addSubview:self.blurredImageView];
到目前为止,我对上一个代码添加/更改的内容进行了最佳拍摄,使用
UIVisualEffectView实现:

- (void)updateData {
    // Set up Screen
    self.screenHeight = [UIScreen mainScreen].bounds.size.height;
    //UIImage *background = [UIImage imageNamed:@"gray"];
    UIImage *background = [UIImage imageNamed:backgroundImageGlobal];

    // Background Image
    self.backgroundImageView = [[UIImageView alloc] initWithImage:background];
    self.backgroundImageView.contentMode = UIViewContentModeScaleAspectFill;
    [self.view addSubview:self.backgroundImageView];

    // Background Image Blurred
    self.blurredImageView = [[UIImageView alloc] init];
    self.blurredImageView.contentMode = UIViewContentModeScaleAspectFill;
    self.blurredImageView.alpha = 0.0; // 0.0
    [self.blurredImageView setImageToBlur:background blurRadius:10 completionBlock:nil]; // blurRadius:10
    [self.view addSubview:self.blurredImageView];
}

- (void)scrollViewDidScroll:(UIScrollView *)scrollView {
    CGFloat height = scrollView.bounds.size.height;
    CGFloat position = MAX(scrollView.contentOffset.y, 0.0);
    CGFloat percent = MIN(position / height, 1.0);
    self.blurredImageView.alpha = percent;
}
// iOS8
@property (nonatomic) UIVisualEffect *blurEffect;
@property (nonatomic) UIVisualEffectView *visualEffectView;

// iOS8 Blur
self.blurredImageView = [[UIImageView alloc] init];
self.blurredImageView.contentMode = UIViewContentModeScaleAspectFill;
self.blurredImageView.alpha = 0.0;
UIBlurEffect *blurEffect = [UIBlurEffect effectWithStyle:UIBlurEffectStyleLight];
UIVisualEffectView *visualEffectView = [[UIVisualEffectView alloc] initWithEffect:blurEffect];
visualEffectView.frame = self.blurredImageView.bounds;
[self.blurredImageView addSubview:visualEffectView];
[self.view addSubview:self.blurredImageView];

我想出来了。我用过:

// iOS8 Blur
UIBlurEffect *blurEffect = [UIBlurEffect effectWithStyle:UIBlurEffectStyleLight];
self.visualEffectViewGlobal = [[UIVisualEffectView alloc] initWithEffect:blurEffect];
self.visualEffectViewGlobal.frame = self.view.bounds;
self.visualEffectViewGlobal.alpha = 0.0;
[self.view addSubview:self.visualEffectViewGlobal];