单元格类CollectionViewCell



#import "CollectionViewCell.h"

@implementation CollectionViewCell

-(id)initWithFrame:(CGRect)frame{
    self = [super initWithFrame:frame];
    if (self) {
        //cellWidth
        CGFloat cellWidth = self.frame.size.width;
        //imageView
        self.imageView = [[UIImageView alloc] initWithFrame:CGRectMake((cellWidth-101)/2, 15, 101, 101)];
        [self addSubview:self.imageView];
        //label
        self.label = [[UILabel alloc] initWithFrame:CGRectMake((cellWidth-101)/2, 120, 101, 16)];
        self.label.textAlignment = NSTextAlignmentCenter;
        self.label.font = [UIFont systemFontOfSize:13];
        [self addSubview:self.label];
    }
    return self;
}

@end

 

你可能感兴趣的:(单元格类CollectionViewCell)