滚动

时间:2015-06-10 22:44:42

标签: ios objective-c uitableview ios8 uiimageview

现在我正在使用LBBlurredImage来模糊图片,但我想更改为 iOS8的{​​{1}}以模糊

我很难实现任何想法?

使用UIVisualEffectView

实施
LBBLurredImage

到目前为止,我最好的注意事项是我添加/更改为以前的代码,使用- (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; } 实现:

UIVisualEffectView

1 个答案:

答案 0 :(得分:0)

我明白了。我用过:

// 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];