131 lines
4.2 KiB
Objective-C
131 lines
4.2 KiB
Objective-C
//
|
|
// XPNewHomePlayEmptyTableViewCell.m
|
|
// YuMi
|
|
//
|
|
// Created by YuMi on 2022/10/8.
|
|
//
|
|
|
|
#import "XPNewHomePlayEmptyTableViewCell.h"
|
|
///Third
|
|
#import <Masonry/Masonry.h>
|
|
///Tool
|
|
#import "DJDKMIMOMColor.h"
|
|
#import "UIImage+Utils.h"
|
|
|
|
@interface XPNewHomePlayEmptyTableViewCell ()
|
|
|
|
///背景
|
|
@property (nonatomic,strong) UIImageView *backImageView;
|
|
///添加
|
|
@property (nonatomic,strong) UIImageView *addImageView;
|
|
///显示标题
|
|
@property (nonatomic,strong) UILabel *titleLabel;
|
|
@property (nonatomic,strong) UIButton *chooseGameBtn;
|
|
@end
|
|
|
|
@implementation XPNewHomePlayEmptyTableViewCell
|
|
|
|
- (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.selectionStyle = UITableViewCellSelectionStyleNone;
|
|
self.backgroundColor = [UIColor clearColor];
|
|
[self.contentView addSubview:self.backImageView];
|
|
[self.backImageView addSubview:self.addImageView];
|
|
[self.backImageView addSubview:self.titleLabel];
|
|
[self.contentView addSubview:self.chooseGameBtn];
|
|
}
|
|
|
|
- (void)initSubViewConstraints {
|
|
[self.backImageView mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
make.right.left.mas_equalTo(self.contentView).inset(15);
|
|
make.top.bottom.mas_equalTo(self.contentView);
|
|
}];
|
|
|
|
[self.addImageView mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
make.size.mas_equalTo(CGSizeMake(48, 48));
|
|
make.left.mas_equalTo(self.backImageView).offset(12);
|
|
make.centerY.mas_equalTo(self.backImageView);
|
|
}];
|
|
|
|
[self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
make.left.mas_equalTo(self.addImageView.mas_right).offset(15);
|
|
make.right.equalTo(self.backImageView.mas_right).mas_offset(-12);
|
|
make.centerY.mas_equalTo(self.backImageView);
|
|
}];
|
|
[self.chooseGameBtn mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
make.right.mas_equalTo(-11);
|
|
make.width.mas_equalTo(120);
|
|
make.top.bottom.equalTo(self.contentView);
|
|
}];
|
|
}
|
|
-(void)chooseGameAction{
|
|
if(self.delegate && [self.delegate respondsToSelector:@selector(emptyCellChooseGameAction)]){
|
|
[self.delegate emptyCellChooseGameAction];
|
|
}
|
|
}
|
|
|
|
-(void)setIsClan:(BOOL)isClan{
|
|
_isClan = isClan;
|
|
if(_isClan == NO){
|
|
_chooseGameBtn.hidden = NO;
|
|
[self.backImageView mas_updateConstraints:^(MASConstraintMaker *make) {
|
|
make.right.mas_equalTo(-141);
|
|
}];
|
|
return;
|
|
}
|
|
_chooseGameBtn.hidden = YES;
|
|
[self.backImageView mas_updateConstraints:^(MASConstraintMaker *make) {
|
|
make.right.mas_equalTo(-15);
|
|
}];
|
|
}
|
|
#pragma mark - Getters And Setters
|
|
|
|
- (UIImageView *)addImageView {
|
|
if (!_addImageView) {
|
|
_addImageView = [[UIImageView alloc] init];
|
|
_addImageView.userInteractionEnabled = YES;
|
|
_addImageView.image = [UIImage imageNamed:@"home_play_create_room"];
|
|
}
|
|
return _addImageView;
|
|
}
|
|
|
|
- (UIImageView *)backImageView {
|
|
if (!_backImageView) {
|
|
_backImageView = [[UIImageView alloc] init];
|
|
_backImageView.image = [UIImage gradientColorImageFromColors:@[[DJDKMIMOMColor colorWithHexString:@"#E7D7FC"], [DJDKMIMOMColor colorWithHexString:@"#D7F8FD"]] gradientType:GradientTypeLeftToRight imgSize:CGSizeMake(10, 10)];
|
|
_backImageView.layer.masksToBounds = YES;
|
|
_backImageView.layer.cornerRadius = 10;
|
|
_backImageView.contentMode = UIViewContentModeScaleAspectFill;
|
|
}
|
|
return _backImageView;
|
|
}
|
|
|
|
- (UILabel *)titleLabel {
|
|
if (!_titleLabel) {
|
|
_titleLabel = [[UILabel alloc] init];
|
|
_titleLabel.font = [UIFont systemFontOfSize:15];
|
|
_titleLabel.textColor = [DJDKMIMOMColor mainTextColor];
|
|
_titleLabel.numberOfLines = 0;
|
|
_titleLabel.text = YMLocalizedString(@"XPNewHomePlayEmptyTableViewCell0");
|
|
}
|
|
return _titleLabel;
|
|
}
|
|
- (UIButton *)chooseGameBtn{
|
|
if (!_chooseGameBtn){
|
|
_chooseGameBtn = [UIButton new];
|
|
[_chooseGameBtn setBackgroundImage:[UIImage imageNamed:@"home_play_game"] forState:UIControlStateNormal];
|
|
[_chooseGameBtn addTarget:self action:@selector(chooseGameAction) forControlEvents:UIControlEventTouchUpInside];
|
|
_chooseGameBtn.hidden = YES;
|
|
}
|
|
return _chooseGameBtn;
|
|
}
|
|
@end
|