// // XGBrowserPhotoCell.m // XGAPP // // Created by 肖浩然的mac on 2020/12/17. // #import "YOUPAIBrowserPhotoCell.h" #import "UIView+NTES.h" #import "TZImagePickerController.h" @implementation YOUPAIBrowserPhotoCell - (instancetype)initWithFrame:(CGRect)frame { self = [super initWithFrame:frame]; if (self) { [self setupUI]; } return self; } -(void)setupUI{ self.backgroundColor = [UIColor whiteColor]; _imageView = [[UIImageView alloc] init]; _imageView.backgroundColor = [UIColor colorWithWhite:1.000 alpha:0.500]; _imageView.contentMode = UIViewContentModeScaleAspectFill; [self.contentView addSubview:_imageView]; [_imageView mas_makeConstraints:^(MASConstraintMaker *make) { make.edges.mas_equalTo(0); }]; _imageView.layer.cornerRadius = 8; _imageView.layer.masksToBounds = YES; _deleteBtn = [UIButton new]; [self.contentView addSubview:_deleteBtn]; [_deleteBtn mas_makeConstraints:^(MASConstraintMaker *make) { make.right.mas_equalTo(0); make.top.mas_equalTo(0); make.size.mas_equalTo(CGSizeMake(15, 15)); }]; [_deleteBtn setImage:[UIImage imageNamed:@"vqu_images_photo_delete"] forState:UIControlStateNormal]; } - (void)setAsset:(PHAsset *)asset { _asset = asset; _videoImageView.hidden = asset.mediaType != PHAssetMediaTypeVideo; _gifLable.hidden = ![[asset valueForKey:@"filename"] containsString:@"GIF"]; } - (void)setRow:(NSInteger)row { _row = row; _deleteBtn.tag = row; } - (UIView *)snapshotView { UIView *snapshotView = [[UIView alloc]init]; UIView *cellSnapshotView = nil; if ([self respondsToSelector:@selector(snapshotViewAfterScreenUpdates:)]) { cellSnapshotView = [self snapshotViewAfterScreenUpdates:NO]; } else { CGSize size = CGSizeMake(self.bounds.size.width + 20, self.bounds.size.height + 20); UIGraphicsBeginImageContextWithOptions(size, self.opaque, 0); [self.layer renderInContext:UIGraphicsGetCurrentContext()]; UIImage * cellSnapshotImage = UIGraphicsGetImageFromCurrentImageContext(); UIGraphicsEndImageContext(); cellSnapshotView = [[UIImageView alloc]initWithImage:cellSnapshotImage]; } snapshotView.frame = CGRectMake(0, 0, cellSnapshotView.frame.size.width, cellSnapshotView.frame.size.height); cellSnapshotView.frame = CGRectMake(0, 0, cellSnapshotView.frame.size.width, cellSnapshotView.frame.size.height); [snapshotView addSubview:cellSnapshotView]; return snapshotView; } @end