YOUPAILZAvatarView.m 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. //
  2. // YOUPAILZAvatarView.m
  3. // VQU
  4. //
  5. // Created by CY on 2021/8/17.
  6. // Copyright © 2021 leo. All rights reserved.
  7. //
  8. #import "YOUPAILZAvatarView.h"
  9. @interface YOUPAILZAvatarView ()
  10. @property (nonatomic,weak)UIImageView *youpaippersonalityBoxImgV;
  11. @property (nonatomic,weak,readwrite)UIImageView *youpaipavatarImgV;
  12. @end
  13. @implementation YOUPAILZAvatarView
  14. + (instancetype)youpaifavatarViewWithFrame:(CGRect)frame avatarURL:(NSURL *)avatarURL personalityBoxURL:(NSURL *)personalityBoxURL{
  15. return [[self alloc] initWithFrame:frame avatarURL:avatarURL personalityBoxURL:personalityBoxURL];
  16. }
  17. - (instancetype)initWithFrame:(CGRect)frame avatarURL:(NSURL *)avatarURL personalityBoxURL:(NSURL *)personalityBoxURL{
  18. if (self = [super initWithFrame:frame]) {
  19. [self youpaifinitUI];
  20. self.youpaipavatarURL = avatarURL;
  21. self.youpaippersonalityBoxURL = personalityBoxURL;
  22. }
  23. return self;
  24. }
  25. - (void)youpaifinitUI{
  26. UIImageView *avatarImgV = [[UIImageView alloc] init];
  27. avatarImgV.contentMode = UIViewContentModeScaleAspectFill;
  28. avatarImgV.layer.cornerRadius = self.mj_w / 2.0f;
  29. avatarImgV.clipsToBounds = YES;
  30. // avatarImgV.layer.borderWidth = 1.0f;
  31. // avatarImgV.layer.borderColor = HexColorFromRGB(0x4F4B5B).CGColor;
  32. [self addSubview:avatarImgV];
  33. self.youpaipavatarImgV = avatarImgV;
  34. [avatarImgV mas_makeConstraints:^(MASConstraintMaker *make) {
  35. make.centerX.equalTo(self.mas_centerX);
  36. make.centerY.equalTo(self.mas_centerY);
  37. make.size.mas_offset(CGSizeMake(self.mj_w, self.mj_h));
  38. }];
  39. UIImageView *personalityBoxImgV = [[UIImageView alloc] init];
  40. [self addSubview:personalityBoxImgV];
  41. self.youpaippersonalityBoxImgV = personalityBoxImgV;
  42. [personalityBoxImgV mas_makeConstraints:^(MASConstraintMaker *make) {
  43. make.centerX.equalTo(self.mas_centerX);
  44. make.centerY.equalTo(self.mas_centerY);
  45. make.size.mas_offset(CGSizeMake(self.mj_w / 0.61f, self.mj_h / 0.61f));
  46. }];
  47. }
  48. - (void)setYoupaipavatarURL:(NSURL *)avatarURL{
  49. _youpaipavatarURL = avatarURL;
  50. [self.youpaipavatarImgV sd_setImageWithURL:avatarURL];
  51. }
  52. - (void)setYoupaippersonalityBoxURL:(NSURL *)personalityBoxURL{
  53. _youpaippersonalityBoxURL = personalityBoxURL;
  54. [self.youpaippersonalityBoxImgV sd_setImageWithURL:personalityBoxURL];
  55. }
  56. @end