XYVoiceMatchOrderDetailsUserItemView.m 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. //
  2. // XYVoiceMatchOrderDetailsUserItemView.m
  3. // Starbuds
  4. //
  5. // Created by 翟玉磊 on 2020/11/20.
  6. // Copyright © 2020 翟玉磊. All rights reserved.
  7. //
  8. #import "XYVoiceMatchOrderDetailsUserItemView.h"
  9. @interface XYVoiceMatchOrderDetailsUserItemView ()
  10. @property (nonatomic, strong) UILabel *titleLabel;
  11. @property (nonatomic, strong) UILabel *userNameLabel;
  12. @end
  13. @implementation XYVoiceMatchOrderDetailsUserItemView
  14. #pragma mark — Public
  15. - (void)setupUserHeadUrl:(NSString *)url userName:(NSString *)name {
  16. [self.userAvatarImageView sd_setImageWithURL:UrlForString(url) placeholderImage:placeholderImage()];
  17. self.userNameLabel.text = name;
  18. }
  19. - (void)setTitle:(NSString *)title {
  20. _title = title;
  21. self.titleLabel.text = title;
  22. }
  23. - (void)setTitleColor:(UIColor *)titleColor {
  24. _titleColor = titleColor;
  25. self.titleLabel.textColor = titleColor;
  26. }
  27. - (instancetype)init
  28. {
  29. self = [super init];
  30. if (self) {
  31. [self setupUI];
  32. }
  33. return self;
  34. }
  35. - (void)setupUI {
  36. [self addSubview:self.titleLabel];
  37. [self addSubview:self.userAvatarImageView];
  38. [self addSubview:self.userNameLabel];
  39. [self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  40. make.centerX.equalTo(self);
  41. make.top.equalTo(self).offset(10.0f);
  42. make.height.equalTo(@20.0f);
  43. }];
  44. [self.userAvatarImageView mas_makeConstraints:^(MASConstraintMaker *make) {
  45. make.centerX.equalTo(self);
  46. make.top.equalTo(self.titleLabel.mas_bottom).offset(5.0f);
  47. make.width.height.equalTo(@42.0f);
  48. }];
  49. [self.userNameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  50. make.centerX.equalTo(self);
  51. make.top.equalTo(self.userAvatarImageView.mas_bottom).offset(4.0f);
  52. make.height.equalTo(@18.0f);
  53. }];
  54. [self.userAvatarImageView addViewBorder:Color_Clear redian:21];
  55. }
  56. #pragma mark — Getter
  57. - (UILabel *)titleLabel {
  58. if (!_titleLabel) {
  59. _titleLabel = [UILabel createLabelTextColor:Color_TextRed fount:Font_S(14)];
  60. _titleLabel.textAlignment = NSTextAlignmentCenter;
  61. }
  62. return _titleLabel;
  63. }
  64. - (UIImageView *)userAvatarImageView {
  65. if (!_userAvatarImageView) {
  66. _userAvatarImageView = [UIImageView new];
  67. _userAvatarImageView.clipsToBounds = YES;
  68. _userAvatarImageView.contentMode = UIViewContentModeScaleAspectFill;
  69. }
  70. return _userAvatarImageView;
  71. }
  72. - (UILabel *)userNameLabel {
  73. if (!_userNameLabel) {
  74. _userNameLabel = [UILabel createLabelTextColor:Color_TextFont fount:Font_B(13)];
  75. _userNameLabel.textAlignment = NSTextAlignmentCenter;
  76. }
  77. return _userNameLabel;
  78. }
  79. @end