YOUPAIHRAgeSexView.m 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. //
  2. // YOUPAIHRAgeSexView.m
  3. // VQU
  4. //
  5. // Created by xiaohaoran on 2021/11/19.
  6. // Copyright © 2021 MS. All rights reserved.
  7. //
  8. #import "YOUPAIHRAgeSexView.h"
  9. @interface YOUPAIHRAgeSexView ()
  10. @property(nonatomic,strong)UIImageView *youpaipsexImageview;
  11. @property(nonatomic,strong)UILabel *youpaipageLabel;
  12. @property(nonatomic,strong)UIView *youpaipbgView;
  13. @end
  14. @implementation YOUPAIHRAgeSexView
  15. -(instancetype)initWithFrame:(CGRect)frame{
  16. if (self = [super initWithFrame:frame]) {
  17. [self youpaifsetSubView];
  18. }
  19. return self;
  20. }
  21. -(void)youpaifsetSubView{
  22. //youpaipbgView
  23. UIView *youpaipbgView = [UIView new];
  24. self.youpaipbgView = youpaipbgView;
  25. [self addSubview:youpaipbgView];
  26. [youpaipbgView mas_makeConstraints:^(MASConstraintMaker *make) {
  27. make.edges.mas_equalTo(0);
  28. }];
  29. youpaipbgView.layer.cornerRadius = 7.5;
  30. youpaipbgView.clipsToBounds = YES;
  31. //性别
  32. UIImageView *youpaipsexImageview = [UIImageView new];
  33. self.youpaipsexImageview = youpaipsexImageview;
  34. [youpaipbgView addSubview:youpaipsexImageview];
  35. [youpaipsexImageview mas_makeConstraints:^(MASConstraintMaker *make) {
  36. make.left.mas_equalTo(4);
  37. make.centerY.mas_equalTo(0);
  38. make.size.mas_equalTo(CGSizeMake(10, 10));
  39. }];
  40. //年龄
  41. UILabel *youpaipageLabel = [UILabel new];
  42. self.youpaipageLabel = youpaipageLabel;
  43. [youpaipbgView addSubview:youpaipageLabel];
  44. [youpaipageLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  45. make.left.mas_equalTo(youpaipsexImageview.mas_right).offset(1);
  46. make.centerY.mas_equalTo(0);
  47. }];
  48. youpaipageLabel.font = [UIFont systemFontOfSize:9];
  49. }
  50. -(void)youpaifreloadWith:(NSInteger)Gender Age:(NSInteger)age{
  51. if (Gender == 1) {//0未知 1女 2男
  52. self.youpaipbgView.backgroundColor = HexColorFromRGBA(0xFF70CF, 0.09);
  53. self.youpaipsexImageview.image = [UIImage imageNamed:@"vqu_images_common_girl"];
  54. self.youpaipageLabel.textColor = HexColorFromRGB(0xFF70CF);
  55. }else{
  56. self.youpaipageLabel.textColor = HexColorFromRGB(0x70ADFF);
  57. self.youpaipbgView.backgroundColor = HexColorFromRGBA(0x70ADFF, 0.09);
  58. self.youpaipsexImageview.image = [UIImage imageNamed:@"vqu_images_common_boy"];
  59. }
  60. self.youpaipageLabel.text = [NSString stringWithFormat:@"%ld",age];
  61. }
  62. @end