gliubc
6/14/2018 - 2:29 AM

CollectionViewCell

CollectionViewCell

@interface SelectCategoryCollectionViewCell : UICollectionViewCell

@property (strong, nonatomic) UIImageView *imageView;
@property (strong, nonatomic) UILabel *label;

@end
@implementation SelectCategoryCollectionViewCell

- (instancetype)initWithFrame:(CGRect)frame {
    self = [super initWithFrame:frame];
    if (self) {
        self.backgroundColor = [UIColor whiteColor];
        UIImageView *imageView = [UIImageView new];
        imageView.contentMode = UIViewContentModeScaleAspectFit;
        [self.contentView addSubview:imageView];
        [imageView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.width.equalTo(@50);
            make.height.equalTo(@50);
            make.top.equalTo(@15);
            make.centerX.equalTo(self.contentView);
        }];
        self.imageView = imageView;

        UILabel *label = [UILabel new];
        label.textColor = HEXCOLOR(0x383838);
        label.font = [UIFont systemFontOfSize:11];
        label.textAlignment = NSTextAlignmentCenter;
        [self.contentView addSubview:label];
        [label mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.right.equalTo(self.contentView);
            make.bottom.equalTo(@-10);
        }];
        self.label = label;
    }
    return self;
}

@end