127 lines
4.4 KiB
Objective-C
127 lines
4.4 KiB
Objective-C
//
|
|
// XPHomeLikeTableViewCell.m
|
|
// xplan-ios
|
|
//
|
|
// Created by 冯硕 on 2022/3/3.
|
|
//
|
|
|
|
#import "XPHomeLikeEmptyTableViewCell.h"
|
|
///Third
|
|
#import <Masonry/Masonry.h>
|
|
///Tool
|
|
#import "ThemeColor.h"
|
|
#import "UIImageConstant.h"
|
|
#import "UIImage+Utils.h"
|
|
@interface XPHomeLikeEmptyTableViewCell ()
|
|
///标题
|
|
@property (nonatomic,strong) UILabel *titleLabel;
|
|
///空图片
|
|
@property (nonatomic,strong) UIImageView *emptyImageView;
|
|
///空文本
|
|
@property (nonatomic,strong) UILabel *emptyLabel;
|
|
///交友畅聊
|
|
@property (nonatomic,strong) UIButton *friendChatButton;
|
|
@end
|
|
|
|
|
|
@implementation XPHomeLikeEmptyTableViewCell
|
|
- (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.titleLabel];
|
|
[self.contentView addSubview:self.emptyImageView];
|
|
[self.contentView addSubview:self.emptyLabel];
|
|
[self.contentView addSubview:self.friendChatButton];
|
|
}
|
|
|
|
- (void)initSubViewConstraints {
|
|
[self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
make.top.mas_equalTo(self.contentView).offset(65);
|
|
make.left.right.mas_equalTo(self.contentView).inset(69);
|
|
}];
|
|
|
|
[self.emptyImageView mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
make.centerX.mas_equalTo(self.contentView);
|
|
make.top.mas_equalTo(self.titleLabel.mas_bottom).offset(68);
|
|
make.size.mas_equalTo(CGSizeMake(200, 178));
|
|
}];
|
|
|
|
[self.emptyLabel mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
make.top.mas_equalTo(self.emptyImageView.mas_bottom).offset(25);
|
|
make.left.right.mas_equalTo(self.contentView);
|
|
}];
|
|
|
|
[self.friendChatButton mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
make.left.right.mas_equalTo(self.contentView).inset(69);
|
|
make.height.mas_equalTo(40);
|
|
make.top.mas_equalTo(self.emptyLabel.mas_bottom).offset(41);
|
|
}];
|
|
}
|
|
#pragma mark - Event Response
|
|
- (void)friendChatButtonAction:(UIButton *)sender {
|
|
if (self.delegate && [self.delegate respondsToSelector:@selector(xPHomeLikeEmptyTableViewCell:didClickFriendChat:)]) {
|
|
[self.delegate xPHomeLikeEmptyTableViewCell:self didClickFriendChat:sender];
|
|
}
|
|
}
|
|
|
|
#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:14];
|
|
_titleLabel.textAlignment = NSTextAlignmentCenter;
|
|
_titleLabel.numberOfLines = 2;
|
|
_titleLabel.textColor = [ThemeColor mainTextColor];
|
|
}
|
|
return _titleLabel;
|
|
}
|
|
|
|
- (UILabel *)emptyLabel {
|
|
if (!_emptyLabel) {
|
|
_emptyLabel = [[UILabel alloc] init];
|
|
_emptyLabel.text = @"有许多有趣的人和房间等着你来发掘哦~";
|
|
_emptyLabel.font = [UIFont systemFontOfSize:14];
|
|
_emptyLabel.textAlignment = NSTextAlignmentCenter;
|
|
_emptyLabel.textColor = [ThemeColor mainTextColor];
|
|
}
|
|
return _emptyLabel;
|
|
}
|
|
|
|
- (UIButton *)friendChatButton {
|
|
if (!_friendChatButton) {
|
|
_friendChatButton = [UIButton buttonWithType:UIButtonTypeCustom];
|
|
[_friendChatButton setTitle:@"交友畅聊" forState:UIControlStateNormal];
|
|
[_friendChatButton setTitleColor:[ThemeColor confirmButtonTextColor] forState:UIControlStateNormal];
|
|
_friendChatButton.titleLabel.font = [UIFont systemFontOfSize:16];
|
|
[_friendChatButton setBackgroundImage:[UIImage gradientColorImageFromColors:@[[ThemeColor confirmButtonGradientStartColor], [ThemeColor confirmButtonGradientEndColor]] gradientType:GradientTypeLeftToRight imgSize:CGSizeMake(10, 10)] forState:UIControlStateNormal];
|
|
_friendChatButton.layer.masksToBounds = YES;
|
|
_friendChatButton.layer.cornerRadius = 20;
|
|
[_friendChatButton addTarget:self action:@selector(friendChatButtonAction:) forControlEvents:UIControlEventTouchUpInside];
|
|
}
|
|
return _friendChatButton;
|
|
}
|
|
|
|
|
|
@end
|