123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687 |
- //
- // LDMenuCollectionCell.m
- // YouHuiProject
- //
- // Created by liuxueli on 2019/1/17.
- // Copyright © 2019 kuxuan. All rights reserved.
- //
- #import "LDMenuCollectionCell.h"
- @implementation LDMenuCollectionCell
- - (instancetype)initWithFrame:(CGRect)frame {
- self = [super initWithFrame:frame];
- if (self) {
- [self addSubview:self.iconimgV];
- [self addSubview:self.titleLabel];
- [self addSubview:self.redlabel];
- CGFloat heights= (self.width-45)/2;
- [self.iconimgV mas_makeConstraints:^(MASConstraintMaker *make) {
- make.width.mas_equalTo(22);
- make.height.mas_equalTo(22);
- make.top.mas_equalTo(FITSIZE(heights));
- make.centerX.mas_equalTo(self.mas_centerX);
- }];
- [self.redlabel mas_makeConstraints:^(MASConstraintMaker *make) {
- make.width.height.mas_equalTo(10);
- make.left.mas_equalTo(self.iconimgV.mas_right).offset(2);
- make.top.mas_equalTo(self.iconimgV.mas_top).offset(-5);
- }];
- [self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
- make.top.mas_equalTo(self.iconimgV.mas_bottom).offset(14);
- make.width.mas_equalTo(self.width);
- }];
- }
- return self;
- }
- -(void)setModel:(LDMineToolModel *)model
- {
- _model = model;
- [self.iconimgV sd_setImageWithURL:[NSURL URLWithString:model.icon]];
- self.titleLabel.text=model.title;
- if (model.show_spot.integerValue == 1) {
- self.redlabel.hidden=NO;
-
- }else{
- self.redlabel.hidden=YES;
- }
- }
- -(UIImageView *)iconimgV
- {
- if (!_iconimgV) {
- _iconimgV =[[UIImageView alloc]init];
- _iconimgV.image=[UIImage imageNamed:@"placeHolder"];
-
- }
- return _iconimgV;
- }
- -(UILabel *)titleLabel
- {
- if (!_titleLabel) {
- _titleLabel =[[UILabel alloc]init];
- _titleLabel.textColor=[UIColor YHColorWithHex:0x7c7c7c];
- _titleLabel.font=[UIFont systemFontOfSize:12];
- _titleLabel.textAlignment=NSTextAlignmentCenter;
-
- }
- return _titleLabel;
- }
- -(UILabel *)redlabel
- {
- if (!_redlabel) {
- _redlabel =[[UILabel alloc]init];
- _redlabel.font=[UIFont systemFontOfSize:9];
- _redlabel.backgroundColor=[UIColor colorWithRed:250/255.0 green:44/255.0 blue:54/255.0 alpha:1.0];
- // _redlabel.text=@"拆";
- _redlabel.textColor=[UIColor whiteColor];
- _redlabel.layer.cornerRadius=5;
- _redlabel.hidden=YES;
- _redlabel.layer.masksToBounds=YES;
- _redlabel.textAlignment=NSTextAlignmentCenter;
- }
- return _redlabel;
- }
- @end
|