123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475 |
- //
- // KXNewTeachCollectionViewCell.m
- // CAISHEN
- //
- // Created by 小花 on 2017/11/8.
- // Copyright © 2017年 kuxuan. All rights reserved.
- //
- #import "KXNewTeachCollectionViewCell.h"
- @interface KXNewTeachCollectionViewCell()
- @property (nonatomic, strong) UIImageView *iconImgView;
- @property (nonatomic, strong) UILabel *titleLabel;
- @end
- @implementation KXNewTeachCollectionViewCell
- - (instancetype)initWithFrame:(CGRect)frame {
- self = [super initWithFrame:frame];
- if (self) {
- self.contentView.backgroundColor = [UIColor KXColorWithHex:0xf9f9f9];
- [self setUpSubViews];
- }
- return self;
- }
- - (void)setUpSubViews {
- [self.contentView addSubview:self.iconImgView];
- [self.contentView addSubview:self.titleLabel];
-
- [self.iconImgView mas_makeConstraints:^(MASConstraintMaker *make) {
- make.centerX.mas_equalTo(self.contentView.mas_centerX);
- make.top.mas_offset(Fitsize(20));
- make.width.height.mas_equalTo(Fitsize(57));
- }];
-
- [self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
- make.centerX.mas_equalTo(self.iconImgView.mas_centerX);
- make.top.mas_equalTo(self.iconImgView.mas_bottom).mas_offset(Fitsize(5));
- make.width.mas_equalTo(Fitsize(150));
- make.height.mas_equalTo(30);
- }];
- }
- - (void)setTitle:(NSString *)title andImage:(NSString *)imageName {
- self.titleLabel.text = title;
- self.iconImgView.image = [UIImage imageNamed:imageName];
- }
- #pragma mark ---------- lazying--------------
- - (UIImageView *)iconImgView {
- if (!_iconImgView) {
- _iconImgView = [[UIImageView alloc] init];
- }
- return _iconImgView;
- }
- - (UILabel *)titleLabel {
- if (!_titleLabel) {
- _titleLabel = [[UILabel alloc] init];
- _titleLabel.textAlignment = NSTextAlignmentCenter;
- _titleLabel.font = [UIFont systemFontOfSize:Fitsize(13)];
- _titleLabel.textColor = [UIColor KXColorWithHex:0xa1a1a1];
- }
- return _titleLabel;
- }
- @end
|