iOS毛玻璃效果

效果如下图

iOS毛玻璃效果_第1张图片
Paste_Image.png

代码如下

- (void)creatVisulBg {
    UIImageView *bgImg = [[UIImageView alloc] initWithFrame:self.bounds];
    bgImg.image = [UIImage imageNamed:@"bg.jpeg"];
    bgImg.contentMode = UIViewContentModeScaleToFill;
    bgImg.userInteractionEnabled = YES;
    [self addSubview:bgImg];
    
    //添加毛玻璃效果
    UIVisualEffectView *effectView = [[UIVisualEffectView alloc] initWithEffect:[UIBlurEffect effectWithStyle:UIBlurEffectStyleLight]];
    effectView.frame = CGRectMake(0, 0, bgImg.frame.size.width, bgImg.frame.size.height);
    [bgImg addSubview:effectView];
}

你可能感兴趣的:(iOS毛玻璃效果)