84 lines
2.3 KiB
Objective-C
84 lines
2.3 KiB
Objective-C
//
|
|
// XPNewHomePlayItemCollectionViewCell.m
|
|
// YuMi
|
|
//
|
|
// Created by YuMi on 2022/10/8.
|
|
//
|
|
|
|
#import "XPNewHomePlayItemCollectionViewCell.h"
|
|
///Third
|
|
#import <Masonry/Masonry.h>
|
|
///Tool
|
|
#import "NetImageView.h"
|
|
///Model
|
|
#import "HomePlayRoomModel.h"
|
|
|
|
@interface XPNewHomePlayItemCollectionViewCell ()
|
|
///边框
|
|
@property (nonatomic,strong) UIImageView *borderImageView;
|
|
///头像
|
|
@property (nonatomic,strong) NetImageView *avatarImageView;
|
|
@end
|
|
|
|
@implementation XPNewHomePlayItemCollectionViewCell
|
|
|
|
- (instancetype)initWithFrame:(CGRect)frame {
|
|
self = [super initWithFrame:frame];
|
|
if (self) {
|
|
[self initSubViews];
|
|
[self initSubViewConstraints];
|
|
}
|
|
return self;
|
|
}
|
|
|
|
#pragma mark - Private Method
|
|
- (void)initSubViews {
|
|
self.contentView.backgroundColor = [UIColor clearColor];
|
|
[self.contentView addSubview:self.borderImageView];
|
|
[self.contentView addSubview:self.avatarImageView];
|
|
}
|
|
|
|
- (void)initSubViewConstraints {
|
|
[self.borderImageView mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
make.edges.mas_equalTo(self.contentView);
|
|
}];
|
|
|
|
[self.avatarImageView mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
make.size.mas_equalTo(CGSizeMake(52, 52));
|
|
make.center.mas_equalTo(self.borderImageView);
|
|
}];
|
|
}
|
|
|
|
#pragma mark - Getters And Setters
|
|
- (void)setRoomInfo:(HomePlayRoomModel *)roomInfo {
|
|
_roomInfo = roomInfo;
|
|
if (_roomInfo != nil) {
|
|
self.avatarImageView.imageUrl = _roomInfo.avatar;
|
|
self.borderImageView.image = _roomInfo.gender == GenderType_Male ? [UIImage imageNamed:@"home_play_male_border"] : [UIImage imageNamed:@"home_play_female_border"];
|
|
}
|
|
}
|
|
|
|
- (UIImageView *)borderImageView {
|
|
if (!_borderImageView) {
|
|
_borderImageView = [[UIImageView alloc] init];
|
|
_borderImageView.userInteractionEnabled = YES;
|
|
}
|
|
return _borderImageView;
|
|
}
|
|
|
|
- (NetImageView *)avatarImageView {
|
|
if (!_avatarImageView) {
|
|
NetImageConfig * config = [[NetImageConfig alloc]init];
|
|
config.imageType = ImageTypeUserIcon;
|
|
config.placeHolder = [UIImageConstant defaultAvatarPlaceholder];
|
|
_avatarImageView = [[NetImageView alloc] initWithConfig:config];
|
|
_avatarImageView.layer.masksToBounds = YES;
|
|
_avatarImageView.layer.cornerRadius = 52/2;
|
|
_avatarImageView.layer.borderColor = [UIColor whiteColor].CGColor;
|
|
_avatarImageView.layer.borderWidth = 1;
|
|
}
|
|
return _avatarImageView;
|
|
}
|
|
|
|
@end
|