86 lines
2.4 KiB
Mathematica
86 lines
2.4 KiB
Mathematica
|
|
//
|
||
|
|
// THBottleInfoImagesCollectionCell.m
|
||
|
|
// TreeHole
|
||
|
|
//
|
||
|
|
// Created by iOS on 2023/2/10.
|
||
|
|
// Copyright © 2023 CYH. All rights reserved.
|
||
|
|
//
|
||
|
|
|
||
|
|
#import "THBottleInfoImagesCollectionCell.h"
|
||
|
|
|
||
|
|
@interface THBottleInfoImagesCollectionCell ()
|
||
|
|
|
||
|
|
@property(nonatomic, strong)UIImageView *imgView;
|
||
|
|
@property(nonatomic, strong)UIVisualEffectView *effectView;
|
||
|
|
|
||
|
|
//@property(nonatomic, copy)NSString *curImgUrl;
|
||
|
|
|
||
|
|
@end
|
||
|
|
|
||
|
|
@implementation THBottleInfoImagesCollectionCell
|
||
|
|
|
||
|
|
- (void)setImg:(id)img {
|
||
|
|
_img = img;
|
||
|
|
if ([img isKindOfClass:UIImage.class]) {
|
||
|
|
self.imgView.image = img;
|
||
|
|
return;
|
||
|
|
}
|
||
|
|
if ([img isKindOfClass:NSString.class]) {
|
||
|
|
[self.imgView sd_setImageWithURL:[NSURL URLWithString:img] placeholderImage:UIImageMake(@"")];
|
||
|
|
return;
|
||
|
|
}
|
||
|
|
if ([img isKindOfClass:NSURL.class]) {
|
||
|
|
[self.imgView sd_setImageWithURL:img placeholderImage:UIImageMake(@"")];
|
||
|
|
return;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
- (void)setImage:(NSString *)imgUrl {
|
||
|
|
// if ([imgUrl isEqualToString:self.curImgUrl]) {
|
||
|
|
// return;
|
||
|
|
// }
|
||
|
|
// _curImgUrl = imgUrl;
|
||
|
|
[self.imgView sd_setImageWithURL:[NSURL URLWithString:imgUrl] placeholderImage:UIImageMake(@"") completed:^(UIImage * _Nullable image, NSError * _Nullable error, SDImageCacheType cacheType, NSURL * _Nullable imageURL) {
|
||
|
|
|
||
|
|
}];
|
||
|
|
}
|
||
|
|
|
||
|
|
- (void)setIsShowEffect:(BOOL)isShowEffect {
|
||
|
|
_isShowEffect = isShowEffect;
|
||
|
|
|
||
|
|
self.effectView.hidden = !isShowEffect;
|
||
|
|
}
|
||
|
|
|
||
|
|
- (instancetype)initWithFrame:(CGRect)frame {
|
||
|
|
if (self = [super initWithFrame:frame]) {
|
||
|
|
[self setupSubViews];
|
||
|
|
}
|
||
|
|
return self;
|
||
|
|
}
|
||
|
|
|
||
|
|
- (void)setupSubViews {
|
||
|
|
_imgView = [UIImageView creatViewInSuperView:self.contentView];
|
||
|
|
_imgView.contentMode = UIViewContentModeScaleAspectFill;
|
||
|
|
_imgView.layer.borderColor = UIColor.whiteColor.CGColor;
|
||
|
|
_imgView.layer.borderWidth = 1;
|
||
|
|
// _imgView.layer.cornerRadius = 10;
|
||
|
|
_imgView.layer.masksToBounds = YES;
|
||
|
|
|
||
|
|
// 高斯模糊的效果
|
||
|
|
UIBlurEffect *blur = [UIBlurEffect effectWithStyle:UIBlurEffectStyleLight];
|
||
|
|
_effectView = [[UIVisualEffectView alloc] initWithEffect:blur];
|
||
|
|
_effectView.alpha = 0.7;
|
||
|
|
[_imgView addSubview:_effectView];
|
||
|
|
|
||
|
|
}
|
||
|
|
- (void)layoutSubviews {
|
||
|
|
[super layoutSubviews];
|
||
|
|
|
||
|
|
self.imgView.frame = self.contentView.bounds;
|
||
|
|
self.imgView.layer.cornerRadius = self.imgView.qmui_height * 0.2;
|
||
|
|
|
||
|
|
self.effectView.frame = self.imgView.bounds;
|
||
|
|
}
|
||
|
|
|
||
|
|
@end
|