2016-01-08 366 views
0

模糊任何圖像時,我想增加模糊效果。這可能是通過添加某種模糊提升?如何添加模糊增強模糊?

這是我使用模糊代碼:

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

不能修改UIVisualEffectView的行爲。如果你想自己模糊,你需要使用模糊的CIFilter或者可以做同樣事情的第三方庫(例如GPUImage)。