模糊任何图像时,我想增加模糊的效果。这是否可以通过添加某种模糊提升来实现?
这是我用来模糊的代码:
- (void)Blur:(UIView *)view {
UIView *blurView = nil;
if([UIBlurEffect class]) {
UIBlurEffect *blurEffect = [UIBlurEffect effectWithStyle:UIBlurEffectStyleDark]; //Can do dark, light or extra light here
blurView = [[UIVisualEffectView alloc] initWithEffect:blurEffect];
blurView.frame = view.frame;
} else {
blurView = [[UIToolbar alloc] initWithFrame:view.bounds];
}
[blurView setTranslatesAutoresizingMaskIntoConstraints:NO];
[view addSubview:blurView];
[view addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"H:|[blurView]|" options:0 metrics:0 views:NSDictionaryOfVariableBindings(blurView)]];
[view addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"V:|[blurView]|" options:0 metrics:0 views:NSDictionaryOfVariableBindings(blurView)]];
}
答案 0 :(得分:0)
您无法修改UIVisualEffectView的行为。如果你想要自己的模糊,你需要使用模糊CIFilter或可以做同样事情的第三方库(例如GPUImage)。