我目前尝试在 View 上添加模糊动画以进行过渡。
我正在使用实现 GPUImageGaussianBlurFilter
的 GPUImage
框架。
它可以工作,但应用于滤镜的效果不够强。我尝试使用 filter.blurRadiusInPixels
值,但它似乎不会改变我尝试输入的任何值。
这是我的代码:
//First I init a ImageView which have the size of the frame of my view
UIImageView * blurredArea = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height)];
//hide this imageView for the moment
blurredArea.alpha = 0;
//In this part I take a snapshot of my current view that I keep in snapshot
UIGraphicsBeginImageContextWithOptions(self.view.bounds.size, self.view.opaque, 0.0);
[self.view.layer renderInContext:UIGraphicsGetCurrentContext()];
UIImage * snapshot=UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
//Finally I init my GaussianFilter on my snapshot
GPUImageGaussianBlurFilter * filter = [[GPUImageGaussianBlurFilter alloc] init];
UIImage * blurred = [filter imageByFilteringImage: snapshot];
blurredArea.image = blurred;
//Here I define the strength of the blur effect but it seems to do nothing whatever the value is putted.
filter.blurRadiusInPixels = 1;
[self.view addSubview:blurredArea];
[UIView animateWithDuration:0.8f animations:^{
//Animate the blurred imageview alpha but not enough blurred.
blurredArea.alpha = 1;
}
最佳答案
如果你只想在通知中心做一些看起来像 iOS 模糊的模糊(我建议你这样做),从 iOS8 开始,UIView 有一个很棒的扩展,叫做 UIVisualEffectView。
有一些链接可以让您逐步实现该杰作:
- > http://applidium.com/en/news/mastering_blur_and_vibrancy_with_iOS_8/
- > http://www.raywenderlich.com/84043/ios-8-visual-effects-tutorial
当然,这仅适用于 iOS8,因此它可能不适合您,但我将其放在将搜索类似解决方案的其他人身上。
关于ios - 使用 GPUImage 的模糊 View 动画,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31606012/