//
需要模糊效果的
view
UIImageView *i = [[ UIImageView alloc ] initWithFrame : CGRectMake ( 100 , 100 , 100 , 200 )];
[ self . view addSubview :i];
i. image = [ UIImage imageNamed : @"1" ];
// 创建 UIBlurEffect
UIBlurEffect *blurEffect = [ UIBlurEffect effectWithStyle : UIBlurEffectStyleLight ];
//UIVisualEffectView
UIVisualEffectView *effectView = [[ UIVisualEffectView alloc ] initWithEffect :blurEffect];
UIImageView *i = [[ UIImageView alloc ] initWithFrame : CGRectMake ( 100 , 100 , 100 , 200 )];
[ self . view addSubview :i];
i. image = [ UIImage imageNamed : @"1" ];
// 创建 UIBlurEffect
UIBlurEffect *blurEffect = [ UIBlurEffect effectWithStyle : UIBlurEffectStyleLight ];
//UIVisualEffectView
UIVisualEffectView *effectView = [[ UIVisualEffectView alloc ] initWithEffect :blurEffect];
//设置模糊效果的frame
effectView.frame = i.bounds;
//
添加到view上
[i
addSubview
:effectView];
//设置模糊的程度
effectView.alpha = .5f;
typedef
NS_ENUM
(NSInteger, UIBlurEffectStyle) {
UIBlurEffectStyleExtraLight,
UIBlurEffectStyleLight,
UIBlurEffectStyleDark
UIBlurEffectStyleDark
}