iOS毛玻璃效果

2017-03-15  本文已影响35人  码农小白

效果如下图

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];
}
上一篇下一篇

猜你喜欢

热点阅读