Skip to content

Latest commit

 

History

History
88 lines (62 loc) · 2.32 KB

README.md

File metadata and controls

88 lines (62 loc) · 2.32 KB

中文版 | English Version

如果能帮助到你,请你给一颗星,谢谢!

DYFBlurEffect

我们使用DYFBlurEffect可以快速实现模糊图像,并支持系统UIVisualEffectView

License MIT  CocoaPods  CocoaPods 

QQ群 (ID:614799921)

安装

使用 CocoaPods:

pod 'DYFBlurEffect'

Or

pod 'DYFBlurEffect', '~> 2.1.1'

预览

使用

  • 实例化
// Lazy load
- (DYFBlurEffect *)blurEffect {
    if (!_blurEffect) {
        _blurEffect = [[DYFBlurEffect alloc] init];
    }
    return _blurEffect;
}
  • 使用 CoreGraphics and vImage
// Uses a `DYFBlurEffectStyle` style.
self.imgView.image = [self.blurEffect blurryImage:image style:DYFBlurEffectLight];

// Tints with a color.
self.imgView.image = [self.blurEffect blurryImage:image tintColor:[UIColor colorWithRed:40/255.0 green:40/255.0 blue:40/255.0 alpha:1]];
/**
Blur out an image with an original image, a blur radius, tint with a color, a saturation delta factor and a mask image.
*/
- (UIImage *)blurryImage:(UIImage *)image blurRadius:(CGFloat)blurRadius tintColor:(UIColor *)tintColor saturationDeltaFactor:(CGFloat)saturationDeltaFactor maskImage:(UIImage *)maskImage;
  • 使用 UIVisualEffectView (Available iOS 8.0 or later)
UIVisualEffectView *blurView = [self.blurEffect blurViewWithStyle:UIBlurEffectStyleLight];
blurView.frame = self.imgView.bounds;
//blurView.tag = 10;
//blurView.userInteractionEnabled = YES;
[self.view addSubview:blurView];
  • 使用 CoreImage
 self.imgView.image = [self.blurEffect coreImage:image blurRadius:10];

示例

如需了解更多,请到这里