zoukankan      html  css  js  c++  java
  • 图片视频毛玻璃效果实现

    毛玻璃效果主要实现就是在图片(imageview)上加一个 UIVisualEffectView

    @property (nonatomic, strong) UIVisualEffectView *effectView;// 毛玻璃处理模糊图片
    #import "VideoTableViewCell.h"
    #import "UIImageView+WebCache.h"
    
    @interface VideoTableViewCell()
    @property (nonatomic, strong) UIImageView *vadioImageView; // 模糊图片
    @property (nonatomic, strong) UIVisualEffectView *effectView;// 毛玻璃处理模糊图片
    @property (nonatomic, strong) UIImageView *backgroundIV;
    
    @end
    
    @implementation VideoTableViewCell
    - (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
    {
        if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
            self.selectionStyle = UITableViewCellSelectionStyleNone;
            self.separatorInset = UIEdgeInsetsZero;
            
            [self.contentView addSubview:self.vadioImageView];// 模糊图片
            [self.contentView addSubview:self.effectView];// 毛玻璃处理模糊图片
            [self.contentView addSubview:self.backgroundIV]; // 清晰图片
            
            __weak typeof(self)weakself = self;
            [self.backgroundIV mas_makeConstraints:^(MASConstraintMaker *make) {
                make.top.equalTo(weakself.mas_top).offset(10 / WIDTH_6S_SCALE);
                make.left.right.equalTo(weakself);
                make.height.mas_offset(IMG_HEIGHT / WIDTH_6S_SCALE);
            }];
            [self.vadioImageView mas_makeConstraints:^(MASConstraintMaker *make) {
                make.top.equalTo(weakself.mas_top).offset(10 / WIDTH_6S_SCALE);
                make.left.right.equalTo(weakself);
                make.height.mas_offset(IMG_HEIGHT / WIDTH_6S_SCALE);
            }];
            [self.effectView mas_makeConstraints:^(MASConstraintMaker *make) {
                make.top.equalTo(weakself.mas_top).offset(10 / WIDTH_6S_SCALE);
                make.left.right.equalTo(weakself);
                make.height.mas_offset(IMG_HEIGHT / WIDTH_6S_SCALE);
            }];
            
            [self.contentView mas_makeConstraints:^(MASConstraintMaker *make) {
                make.top.equalTo(weakself.backgroundIV.mas_top).offset(-10 / HEIGHT_6S_SCALE);
                make.left.right.equalTo(weakself);
                make.bottom.equalTo(weakself.backgroundIV.mas_bottom).offset(10 / HEIGHT_6S_SCALE);
            }];
        }
        return self;
    }
    #pragma mark - set
    - (void)setHomePageModelList:(HomePageModelList *)homePageModelList
    {
        _homePageModelList = homePageModelList;
        NSURL *videoUrl = [NSURL URLWithStringAddOffset:self.homePageModelList.file];
        WS(ws);
        [UIImage getImageFromVideoURLString:videoUrl.absoluteString handle:^(NSDictionary *dic) {
            ws.backgroundIV.image = dic[@"image"];
            ws.vadioImageView.image = dic[@"image"];
        }];
    }
    #pragma mark - init
    - (UIImageView *)backgroundIV
    {
        if (!_backgroundIV) {
            _backgroundIV = [[UIImageView alloc]init];
            _backgroundIV.contentMode = UIViewContentModeScaleAspectFit;
        }
        return _backgroundIV;
    }
    - (UIImageView *)vadioImageView
    {
        if (!_vadioImageView)
        {
            _vadioImageView = [[UIImageView alloc]init];
            _vadioImageView.backgroundColor = [UIColor grayColor];
            _vadioImageView.image = [UIImage imageNamed:@"h4"];
            //        _vadioImageView.contentMode = UIViewContentModeScaleAspectFit;
        }
        return _vadioImageView;
    }
    
    - (UIVisualEffectView *)effectView
    {
        if (!_effectView)
        {
            _effectView = [[UIVisualEffectView alloc] initWithEffect:[UIBlurEffect effectWithStyle:UIBlurEffectStyleLight]];
            _effectView.alpha = 0.9f;
        }
        return _effectView;
    }
    @end
  • 相关阅读:
    怎样理解 C++ 11中的move语义
    面试---计算机网络
    TCP报头中的选项字段
    协程的实现之调度器
    CPU缓存
    TLS---线程局部存储
    微信libco协程设计及实现---总结
    libco源码解析---协程运行与基本结构
    2014年第五届蓝桥杯B组(C/C++)预赛题目及个人答案(欢迎指正)
    并查集(模板&典型例题整理)
  • 原文地址:https://www.cnblogs.com/dujiahong/p/8556314.html
Copyright © 2011-2022 走看看