134 lines
3.8 KiB
Objective-C
134 lines
3.8 KiB
Objective-C
//
|
|
// XPRoomRankEntranceView.m
|
|
// xplan-ios
|
|
//
|
|
// Created by GreenLand on 2022/4/27.
|
|
//
|
|
|
|
#import "XPRoomRankEntranceView.h"
|
|
///Third
|
|
#import <Masonry/Masonry.h>
|
|
#import "ThemeColor.h"
|
|
///Tool
|
|
#import "NetImageView.h"
|
|
|
|
@interface XPRoomRankEntranceView ()
|
|
|
|
///背景图
|
|
@property (nonatomic, strong) UIView *bgView;
|
|
///排行榜容器
|
|
@property (nonatomic, strong) UIView *rankContentView;
|
|
///礼物值
|
|
@property (nonatomic, strong) UILabel *titleLabel;
|
|
///箭头图标
|
|
@property (nonatomic, strong) UIImageView *iconImageView;
|
|
|
|
@end
|
|
|
|
@implementation XPRoomRankEntranceView
|
|
|
|
- (instancetype)initWithFrame:(CGRect)frame {
|
|
if (self = [super initWithFrame:frame]) {
|
|
[self initSubViews];
|
|
[self initSubViewConstraints];
|
|
}
|
|
return self;
|
|
}
|
|
|
|
#pragma mark - Private Method
|
|
- (void)initSubViews {
|
|
[self addSubview:self.bgView];
|
|
[self addSubview:self.rankContentView];
|
|
[self addSubview:self.titleLabel];
|
|
[self addSubview:self.iconImageView];
|
|
for (int i = 0; i < 3; i++) {
|
|
NetImageConfig *config = [[NetImageConfig alloc] init];
|
|
config.placeHolder = [UIImageConstant defaultEmptyAvatarPlaceholder];
|
|
NetImageView *imageView = [[NetImageView alloc] initWithConfig:config];
|
|
imageView.layer.cornerRadius = 10;
|
|
imageView.layer.masksToBounds = YES;
|
|
[self.rankContentView addSubview:imageView];
|
|
[imageView mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
make.centerY.mas_equalTo(self.rankContentView);
|
|
make.width.height.mas_equalTo(20);
|
|
make.left.mas_equalTo(i * 20);
|
|
}];
|
|
}
|
|
}
|
|
|
|
- (void)initSubViewConstraints {
|
|
[self.bgView mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
make.top.bottom.right.left.mas_equalTo(0);
|
|
}];
|
|
[self.rankContentView mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
make.centerY.mas_equalTo(self);
|
|
make.width.mas_equalTo(60);
|
|
make.height.mas_equalTo(20);
|
|
make.left.mas_equalTo(1);
|
|
}];
|
|
[self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
make.centerY.mas_equalTo(self);
|
|
make.left.mas_equalTo(self.rankContentView.mas_right).mas_offset(4);
|
|
}];
|
|
[self.iconImageView mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
make.width.height.mas_equalTo(9);
|
|
make.centerY.mas_equalTo(self);
|
|
make.left.mas_equalTo(self.titleLabel.mas_right).mas_offset(5);
|
|
}];
|
|
}
|
|
|
|
#pragma mark - Getters And Setters
|
|
- (void)setTitle:(NSString *)title {
|
|
self.titleLabel.text = title;
|
|
}
|
|
|
|
- (void)setArray:(NSArray *)array {
|
|
for (int i = 0; i < self.rankContentView.subviews.count; i++) {
|
|
NSString *str;
|
|
if (array.count > i) {
|
|
str = array[i];
|
|
}
|
|
NetImageView *imageView = self.rankContentView.subviews[i];
|
|
imageView.imageUrl = str.length ? str : @"";
|
|
}
|
|
}
|
|
|
|
- (UIView *)bgView {
|
|
if (_bgView == nil) {
|
|
_bgView = [[UIView alloc] init];
|
|
_bgView.backgroundColor = UIColorRGBAlpha(0xFFFFFF, 0.2);
|
|
_bgView.layer.cornerRadius = 11;
|
|
_bgView.layer.masksToBounds = YES;
|
|
}
|
|
return _bgView;
|
|
}
|
|
|
|
- (UIView *)rankContentView {
|
|
if (!_rankContentView) {
|
|
_rankContentView = [[UIView alloc] init];
|
|
}
|
|
return _rankContentView;
|
|
}
|
|
|
|
- (UIImageView *)iconImageView {
|
|
if (_iconImageView == nil) {
|
|
_iconImageView = [[UIImageView alloc] init];
|
|
_iconImageView.image = [UIImage imageNamed:@"room_position_little_game_right_arrow"];
|
|
_iconImageView.contentMode = UIViewContentModeScaleAspectFit;
|
|
}
|
|
return _iconImageView;
|
|
}
|
|
|
|
- (UILabel *)titleLabel {
|
|
if (_titleLabel == nil) {
|
|
_titleLabel = [[UILabel alloc] init];
|
|
_titleLabel.textColor = UIColor.whiteColor;
|
|
_titleLabel.font = [UIFont systemFontOfSize:10 weight:UIFontWeightMedium];
|
|
_titleLabel.text = @"房间榜";
|
|
}
|
|
return _titleLabel;
|
|
}
|
|
|
|
|
|
@end
|