123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293 |
- //
- // XYVoiceMatchOrderDetailsUserItemView.m
- // Starbuds
- //
- // Created by 翟玉磊 on 2020/11/20.
- // Copyright © 2020 翟玉磊. All rights reserved.
- //
- #import "XYVoiceMatchOrderDetailsUserItemView.h"
- @interface XYVoiceMatchOrderDetailsUserItemView ()
- @property (nonatomic, strong) UILabel *titleLabel;
- @property (nonatomic, strong) UILabel *userNameLabel;
- @end
- @implementation XYVoiceMatchOrderDetailsUserItemView
- #pragma mark — Public
- - (void)setupUserHeadUrl:(NSString *)url userName:(NSString *)name {
- [self.userAvatarImageView sd_setImageWithURL:UrlForString(url) placeholderImage:placeholderImage()];
- self.userNameLabel.text = name;
- }
- - (void)setTitle:(NSString *)title {
- _title = title;
- self.titleLabel.text = title;
- }
- - (void)setTitleColor:(UIColor *)titleColor {
- _titleColor = titleColor;
- self.titleLabel.textColor = titleColor;
- }
- - (instancetype)init
- {
- self = [super init];
- if (self) {
- [self setupUI];
- }
- return self;
- }
- - (void)setupUI {
- [self addSubview:self.titleLabel];
- [self addSubview:self.userAvatarImageView];
- [self addSubview:self.userNameLabel];
-
- [self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
- make.centerX.equalTo(self);
- make.top.equalTo(self).offset(10.0f);
- make.height.equalTo(@20.0f);
- }];
- [self.userAvatarImageView mas_makeConstraints:^(MASConstraintMaker *make) {
- make.centerX.equalTo(self);
- make.top.equalTo(self.titleLabel.mas_bottom).offset(5.0f);
- make.width.height.equalTo(@42.0f);
- }];
- [self.userNameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
- make.centerX.equalTo(self);
- make.top.equalTo(self.userAvatarImageView.mas_bottom).offset(4.0f);
- make.height.equalTo(@18.0f);
- }];
-
- [self.userAvatarImageView addViewBorder:Color_Clear redian:21];
- }
- #pragma mark — Getter
- - (UILabel *)titleLabel {
- if (!_titleLabel) {
- _titleLabel = [UILabel createLabelTextColor:Color_TextRed fount:Font_S(14)];
- _titleLabel.textAlignment = NSTextAlignmentCenter;
- }
- return _titleLabel;
- }
- - (UIImageView *)userAvatarImageView {
- if (!_userAvatarImageView) {
- _userAvatarImageView = [UIImageView new];
- _userAvatarImageView.clipsToBounds = YES;
- _userAvatarImageView.contentMode = UIViewContentModeScaleAspectFill;
- }
- return _userAvatarImageView;
- }
- - (UILabel *)userNameLabel {
- if (!_userNameLabel) {
- _userNameLabel = [UILabel createLabelTextColor:Color_TextFont fount:Font_B(13)];
- _userNameLabel.textAlignment = NSTextAlignmentCenter;
- }
- return _userNameLabel;
- }
- @end
|