猎豆优选

LDShareDesView.m 1.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. //
  2. // LDShareDesView.m
  3. // YouHuiProject
  4. //
  5. // Created by 小花 on 2019/1/2.
  6. // Copyright © 2019年 kuxuan. All rights reserved.
  7. //
  8. #import "LDShareDesView.h"
  9. @interface LDShareDesView ()
  10. @end
  11. @implementation LDShareDesView
  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. if ([[PhoneLoginManager shareManager].showPhoneBtn boolValue]) {
  26. text=@"分享给好友";
  27. }
  28. title.font = [UIFont systemFontOfSize:14];
  29. title.textColor = [UIColor YHColorWithHex:0x666666];
  30. title.textAlignment = NSTextAlignmentCenter;
  31. NSMutableAttributedString *attStr = [[NSMutableAttributedString alloc] initWithString:text];
  32. NSRange range = [text rangeOfString:comPrice];
  33. [attStr addAttribute:NSForegroundColorAttributeName value:[UIColor homeRedColor] range:range];
  34. title.attributedText = attStr;
  35. [title sizeToFit];
  36. title.centerX = self.width/2;
  37. title.centerY = self.height/2;
  38. [self addSubview:title];
  39. UIView *leftLine = [[UIView alloc] initWithFrame:CGRectMake(title.left-70, 0, 60, 1)];
  40. leftLine.backgroundColor = [UIColor YHColorWithHex:0xE5E4E6];
  41. leftLine.centerY = self.height/2;
  42. [self addSubview:leftLine];
  43. UIView *rightLine = [[UIView alloc] initWithFrame:CGRectMake(title.right+10, 0, 60, 1)];
  44. rightLine.backgroundColor = [UIColor YHColorWithHex:0xE5E4E6];
  45. rightLine.centerY = self.height/2;
  46. [self addSubview:rightLine];
  47. }
  48. @end