美文网首页
UIVisualEffectView毛玻璃

UIVisualEffectView毛玻璃

作者: 倪大头 | 来源:发表于2018-05-08 12:58 被阅读26次

    iOS8苹果新增了毛玻璃接口:

    UIImageView *imageV = [[UIImageView alloc]initWithFrame:CGRectMake(0, 0, UI_SCREEN_WIDTH, UI_SCREEN_HEIGHT)];
    imageV.image = [UIImage imageNamed:@"Dva2"];
    imageV.contentMode = UIViewContentModeScaleAspectFill;
    imageV.clipsToBounds = YES;
    [self.view addSubview:imageV];
        
    UIVisualEffectView *visualView = [[UIVisualEffectView alloc]initWithEffect:[UIBlurEffect effectWithStyle:UIBlurEffectStyleLight]];
    visualView.frame = imageV.bounds;
    [imageV addSubview:visualView];
    

    把UIVisualEffectView覆盖在图层上即可,effectWithStyle:参数是个枚举,提供不同亮度的毛玻璃效果

    WX20180508-125811@2x.png

    相关文章

      网友评论

          本文标题:UIVisualEffectView毛玻璃

          本文链接:https://www.haomeiwen.com/subject/rvwirftx.html