.h 文件内容
#import
NS_ASSUME_NONNULL_BEGIN
typedefvoid(^ButtonClick)(UIButton* sender);
@interface SquareImageCollectionCell : UICollectionViewCell
@property (nonatomic,copy) ButtonClick deleteClick;
@property (nonatomic,strong) NSString * cellImg;
@end
NS_ASSUME_NONNULL_END
.m 文件内容
#import "SquareImageCollectionCell.h"
@interface SquareImageCollectionCell()
@property (nonatomic ,strong) UIImageView *imageView;
@end
@implementation SquareImageCollectionCell
- (instancetype)initWithFrame:(CGRect)frame {
if (self = [super initWithFrame:frame]) {
_imageView = [[UIImageView alloc] init];
_imageView.layer.masksToBounds = YES;
_imageView.layer.cornerRadius = 6.5;
_imageView.frame = CGRectMake(0, 0, self.contentView.frame.size.width, self.contentView.frame.size.height);_imageView.contentMode = UIViewContentModeScaleAspectFill;
[self.contentView addSubview:_imageView];
return self;
}
-(void)setCellImg:(NSString*)cellImg{
_imageView.image = [UIImage imageNamed:cellImg];
}
@end
网友评论