毛玻璃效果主要实现就是在图片(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