202 lines
6.9 KiB
Objective-C
202 lines
6.9 KiB
Objective-C
//
|
|
// QXHomeTopView.m
|
|
// QXLive
|
|
//
|
|
// Created by 启星 on 2025/10/20.
|
|
//
|
|
|
|
#import "QXHomeTopView.h"
|
|
@interface QXHomeTopView()<QXHomeTopViewDelegate>
|
|
@property (nonatomic,strong)UIImageView *hotRoomImageView;
|
|
@property (nonatomic,strong)UIImageView *hotIconImageView;
|
|
@property (nonatomic,strong)UILabel *hotLabel;
|
|
@property (nonatomic,strong)UIButton *hotRoomBtn;
|
|
|
|
@property (nonatomic,strong)QXHomeTopSubView *myRoomView;
|
|
|
|
@property (nonatomic,strong)QXHomeTopSubView *rankView;
|
|
|
|
@property (nonatomic,strong)QXHomeTopSubView *noticeView;
|
|
@end
|
|
|
|
@implementation QXHomeTopView
|
|
|
|
- (instancetype)initWithFrame:(CGRect)frame
|
|
{
|
|
self = [super initWithFrame:frame];
|
|
if (self) {
|
|
[self initSubviews];
|
|
}
|
|
return self;
|
|
}
|
|
|
|
-(void)initSubviews{
|
|
self.hotRoomImageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"home_hot_bg"]];
|
|
self.hotRoomImageView.contentMode = UIViewContentModeScaleToFill;
|
|
[self addSubview:self.hotRoomImageView];
|
|
[self.hotRoomImageView mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
make.top.equalTo(self);
|
|
make.left.mas_equalTo(16);
|
|
make.width.mas_equalTo(ScaleWidth(164));
|
|
make.height.mas_equalTo(ScaleWidth(184));
|
|
}];
|
|
|
|
self.hotIconImageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"room_hot_icon"]];
|
|
[self addSubview:self.hotIconImageView];
|
|
[self.hotIconImageView mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
make.left.equalTo(self.hotRoomImageView).offset(12);
|
|
make.top.mas_equalTo(20);
|
|
make.width.height.mas_equalTo(ScaleWidth(18));
|
|
}];
|
|
|
|
self.hotRoomBtn = [[UIButton alloc] init];
|
|
[self.hotRoomBtn setImage:[UIImage imageNamed:@"home_hot_room_goto"] forState:(UIControlStateNormal)];
|
|
[self.hotRoomBtn addTarget:self action:@selector(hotRoomAction) forControlEvents:(UIControlEventTouchUpInside)];
|
|
[self addSubview:self.hotRoomBtn];
|
|
[self.hotRoomBtn mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
make.centerY.equalTo(self.hotIconImageView);
|
|
make.right.equalTo(self.hotRoomImageView);
|
|
make.height.mas_equalTo(40);
|
|
make.width.mas_equalTo(50);
|
|
}];
|
|
|
|
self.hotLabel = [[UILabel alloc] init];
|
|
self.hotLabel.textColor = RGB16(0xF1ECFF);
|
|
self.hotLabel.font = [UIFont fontWithName:@"YouSheBiaoTiHei" size:20];
|
|
self.hotLabel.text = @"热门房间";
|
|
[self addSubview:self.hotLabel];
|
|
[self.hotLabel mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
make.left.equalTo(self.hotIconImageView.mas_right);
|
|
make.right.equalTo(self.hotRoomBtn.mas_left);
|
|
make.centerY.equalTo(self.hotIconImageView);
|
|
}];
|
|
|
|
|
|
|
|
self.myRoomView = [[QXHomeTopSubView alloc] init];
|
|
self.myRoomView.type = QXHomeTopClickTypeMyRoom;
|
|
self.myRoomView.delegate = self;
|
|
[self addSubview:self.myRoomView];
|
|
[self.myRoomView mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
make.top.equalTo(self.hotRoomImageView);
|
|
make.left.equalTo(self.hotRoomImageView.mas_right).offset(14);
|
|
make.right.mas_equalTo(-16);
|
|
make.height.mas_equalTo(ScaleWidth(56));
|
|
}];
|
|
|
|
self.rankView = [[QXHomeTopSubView alloc] init];
|
|
self.rankView.type = QXHomeTopClickTypeRank;
|
|
self.rankView.delegate = self;
|
|
[self addSubview:self.rankView];
|
|
[self.rankView mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
make.centerY.equalTo(self.hotRoomImageView);
|
|
make.left.right.equalTo(self.myRoomView);
|
|
make.height.mas_equalTo(ScaleWidth(56));
|
|
}];
|
|
|
|
self.noticeView = [[QXHomeTopSubView alloc] init];
|
|
self.noticeView.type = QXHomeTopClickTypeNotice;
|
|
self.noticeView.delegate = self;
|
|
[self addSubview:self.noticeView];
|
|
[self.noticeView mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
make.bottom.equalTo(self.hotRoomImageView);
|
|
make.left.right.equalTo(self.myRoomView);
|
|
make.height.mas_equalTo(ScaleWidth(56));
|
|
}];
|
|
}
|
|
|
|
-(void)reloadData{
|
|
|
|
}
|
|
-(void)didClickTopViewType:(QXHomeTopClickType)type{
|
|
if (self.delegate && [self.delegate respondsToSelector:@selector(didClickTopViewType:)]) {
|
|
[self.delegate didClickTopViewType:type];
|
|
}
|
|
}
|
|
|
|
-(void)hotRoomAction{
|
|
if (self.delegate && [self.delegate respondsToSelector:@selector(didClickTopViewType:)]) {
|
|
[self.delegate didClickTopViewType:QXHomeTopClickTypeHotRoom];
|
|
}
|
|
}
|
|
|
|
|
|
@end
|
|
|
|
|
|
@implementation QXHomeTopSubView
|
|
|
|
- (instancetype)init
|
|
{
|
|
self = [super init];
|
|
if (self) {
|
|
[self initSubviews];
|
|
}
|
|
return self;
|
|
}
|
|
|
|
-(void)setType:(QXHomeTopClickType)type{
|
|
_type = type;
|
|
switch (type) {
|
|
case QXHomeTopClickTypeMyRoom:
|
|
self.titleLabel.text = @"我的房间";
|
|
self.subTitleLabel.text = @"进行一场灵魂深聊";
|
|
self.bgImageView.image = [UIImage imageNamed:@"home_my_room_bg"];
|
|
break;
|
|
case QXHomeTopClickTypeRank:
|
|
self.titleLabel.text = @"排行榜";
|
|
self.subTitleLabel.text = @"荣耀之巅 彰显实力";
|
|
self.bgImageView.image = [UIImage imageNamed:@"home_rank_bg"];
|
|
break;
|
|
case QXHomeTopClickTypeNotice:
|
|
self.titleLabel.text = @"官方公告";
|
|
self.subTitleLabel.text = @"政策变动一键留痕";
|
|
self.bgImageView.image = [UIImage imageNamed:@"home_notice_bg"];
|
|
break;
|
|
default:
|
|
break;
|
|
}
|
|
}
|
|
|
|
-(void)initSubviews{
|
|
self.bgImageView = [[UIImageView alloc] init];
|
|
self.bgImageView.contentMode = UIViewContentModeScaleToFill;
|
|
[self addSubview:self.bgImageView];
|
|
[self.bgImageView mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
make.edges.equalTo(self);
|
|
}];
|
|
|
|
self.titleLabel = [[UILabel alloc] init];
|
|
self.titleLabel.textColor = RGB16(0xF1ECFF);
|
|
self.titleLabel.font = [UIFont fontWithName:@"YouSheBiaoTiHei" size:18];
|
|
[self addSubview:self.titleLabel];
|
|
[self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
make.left.equalTo(self.bgImageView).offset(11);
|
|
make.top.equalTo(self.bgImageView).offset(ScaleWidth(8));
|
|
}];
|
|
|
|
self.subTitleLabel = [[UILabel alloc] init];
|
|
self.subTitleLabel.textColor = RGB16(0xF1ECFF);
|
|
self.subTitleLabel.font = [UIFont systemFontOfSize:12];
|
|
[self addSubview:self.subTitleLabel];
|
|
[self.subTitleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
make.left.equalTo(self.titleLabel);
|
|
make.bottom.equalTo(self).offset(-ScaleWidth(6));
|
|
}];
|
|
|
|
self.btn = [[UIButton alloc] init];
|
|
[self.btn addTarget:self action:@selector(btnAction) forControlEvents:(UIControlEventTouchUpInside)];
|
|
[self addSubview:self.btn];
|
|
[self.btn mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
make.edges.equalTo(self);
|
|
}];
|
|
}
|
|
|
|
-(void)btnAction{
|
|
if (self.delegate && [self.delegate respondsToSelector:@selector(didClickTopViewType:)]) {
|
|
[self.delegate didClickTopViewType:self.type];
|
|
}
|
|
}
|
|
|
|
@end
|