单元格类CollectionViewCell

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/sndongcheng/article/details/83418873


#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

猜你喜欢

转载自blog.csdn.net/sndongcheng/article/details/83418873