《省钱达人》与《猎豆优选》UI相同版。域名tbk

DRShareDesView.m 1.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. //
  2. // DRShareDesView.m
  3. // YouHuiProject
  4. //
  5. // Created by 小花 on 2019/1/2.
  6. // Copyright © 2019年 kuxuan. All rights reserved.
  7. //
  8. #import "DRShareDesView.h"
  9. @interface DRShareDesView ()
  10. @end
  11. @implementation DRShareDesView
  12. - (instancetype)initWithFrame:(CGRect)frame commissPrice:(NSString *)commissPrice
  13. {
  14. self = [super initWithFrame:frame];
  15. if (self) {
  16. [self initSubViews:commissPrice];
  17. }
  18. return self;
  19. }
  20. - (void)initSubViews:(NSString *)commissonPrice {
  21. self.backgroundColor = [UIColor clearColor];
  22. UILabel *title = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, Fitsize(65), self.height)];
  23. NSString *comPrice = [NSString stringWithFormat:@"¥%@元",commissonPrice];
  24. NSString *text = [NSString stringWithFormat:@"商品被购买你可赚%@",comPrice];
  25. title.font = [UIFont systemFontOfSize:14];
  26. title.textColor = [UIColor YHColorWithHex:0x666666];
  27. title.textAlignment = NSTextAlignmentCenter;
  28. NSMutableAttributedString *attStr = [[NSMutableAttributedString alloc] initWithString:text];
  29. NSRange range = [text rangeOfString:comPrice];
  30. [attStr addAttribute:NSForegroundColorAttributeName value:[UIColor homeRedColor] range:range];
  31. title.attributedText = attStr;
  32. [title sizeToFit];
  33. title.centerX = self.width/2;
  34. title.centerY = self.height/2;
  35. [self addSubview:title];
  36. UIView *leftLine = [[UIView alloc] initWithFrame:CGRectMake(title.left-70, 0, 60, 1)];
  37. leftLine.backgroundColor = [UIColor YHColorWithHex:0xE5E4E6];
  38. leftLine.centerY = self.height/2;
  39. [self addSubview:leftLine];
  40. UIView *rightLine = [[UIView alloc] initWithFrame:CGRectMake(title.right+10, 0, 60, 1)];
  41. rightLine.backgroundColor = [UIColor YHColorWithHex:0xE5E4E6];
  42. rightLine.centerY = self.height/2;
  43. [self addSubview:rightLine];
  44. }
  45. @end