码迷,mamicode.com
首页 > 其他好文 > 详细

图片视频毛玻璃效果实现

时间:2018-03-13 15:34:10      阅读:239      评论:0      收藏:0      [点我收藏+]

标签:eof   absolute   alt   cts   idt   col   omv   asc   get   

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

 

图片视频毛玻璃效果实现

标签:eof   absolute   alt   cts   idt   col   omv   asc   get   

原文地址:https://www.cnblogs.com/dujiahong/p/8556314.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!