// // XPMonentsEmptyTableViewCell.m // xplan-ios // // Created by 冯硕 on 2022/5/13. // #import "XPMonentsEmptyTableViewCell.h" ///Third #import ///Tool #import "ThemeColor.h" #import "UIImageConstant.h" @interface XPMonentsEmptyTableViewCell () @property (nonatomic,strong) UIImageView *emptyImageView; @property (nonatomic,strong) UILabel *titleLabel; @end @implementation XPMonentsEmptyTableViewCell - (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier { if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) { [self initSubViews]; [self initSubViewConstraints]; } return self; } #pragma mark - Private Method - (void)initSubViews { self.backgroundColor = [UIColor clearColor]; self.selectionStyle = UITableViewCellSelectionStyleNone; [self.contentView addSubview:self.emptyImageView]; [self.contentView addSubview:self.titleLabel]; } - (void)initSubViewConstraints { [self.emptyImageView mas_makeConstraints:^(MASConstraintMaker *make) { make.top.mas_equalTo(self.contentView).offset(150); make.centerX.mas_equalTo(self.contentView); make.size.mas_equalTo(CGSizeMake(200, 200)); }]; [self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) { make.top.mas_equalTo(self.emptyImageView.mas_bottom).offset(20); make.left.right.mas_equalTo(self.contentView); }]; } #pragma mark - Getters And Setters - (UIImageView *)emptyImageView { if (!_emptyImageView) { _emptyImageView = [[UIImageView alloc] init]; _emptyImageView.userInteractionEnabled = YES; _emptyImageView.image = [UIImageConstant defalutEmptyPlaceholder]; _emptyImageView.layer.masksToBounds = YES; _emptyImageView.contentMode = UIViewContentModeScaleAspectFit; } return _emptyImageView; } - (UILabel *)titleLabel { if (!_titleLabel) { _titleLabel = [[UILabel alloc] init]; _titleLabel.text = @"暂无数据"; _titleLabel.font = [UIFont systemFontOfSize:16]; _titleLabel.textAlignment = NSTextAlignmentCenter; _titleLabel.textColor = [ThemeColor secondTextColor]; } return _titleLabel; } @end