酷店

KDPSellingPointView.m 2.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. //
  2. // KDPSellingPointView.m
  3. // KuDianProject
  4. //
  5. // Created by 学丽 on 2019/7/9.
  6. // Copyright © 2019 KDP. All rights reserved.
  7. //
  8. #import "KDPSellingPointView.h"
  9. @implementation KDPSellingPointView
  10. -(instancetype)initWithFrame:(CGRect)frame
  11. {
  12. self =[super initWithFrame:frame];
  13. if (self) {
  14. self.hotView=[[UIView alloc]initWithFrame:CGRectMake(10, 0, SCREEN_WIDTH-20, 0)];
  15. self.hotView.layer.cornerRadius=5;
  16. self.hotView.layer.masksToBounds=YES;
  17. [self addSubview:self.hotView];
  18. self.hotView.backgroundColor=[UIColor colorWithHexString:@"#FEF3E8"];
  19. UIImageView *iconIm=[[UIImageView alloc]initWithFrame:CGRectMake(10, 10, 18, 18)];
  20. iconIm.image=[UIImage imageNamed:@"hot_point"];
  21. [self.hotView addSubview:iconIm];
  22. UILabel *label=[[UILabel alloc]initWithFrame:CGRectMake(iconIm.right+5, iconIm.top, 50, 18)];
  23. label.text=@"卖点:";
  24. label.font=[UIFont systemFontOfSize:13];
  25. label.textColor=[UIColor colorWithHexString:@"#333333"];
  26. [self.hotView addSubview:label];
  27. UIButton *copyBtn=[[UIButton alloc]initWithFrame:CGRectMake(self.hotView.right-70, iconIm.top+1, 50, 16)];
  28. copyBtn.layer.cornerRadius=2;
  29. copyBtn.layer.masksToBounds=YES;
  30. [copyBtn setTitle:@"复制" forState:UIControlStateNormal];
  31. [copyBtn setTitleColor:[UIColor colorWithHexString:@"#999999"] forState:UIControlStateNormal];
  32. copyBtn.titleLabel.font=[UIFont systemFontOfSize:10];
  33. copyBtn.layer.borderWidth=1;
  34. copyBtn.layer.borderColor=[UIColor colorWithHexString:@"#999999"].CGColor;
  35. [self.hotView addSubview:copyBtn];
  36. [copyBtn addTarget:self action:@selector(copyclickButton) forControlEvents:UIControlEventTouchUpInside];
  37. self.pointLabel=[[UILabel alloc]initWithFrame:CGRectMake(10,label.bottom, SCREEN_WIDTH-40, 20)];
  38. self.pointLabel.text=@"----";
  39. self.pointLabel.numberOfLines=0;
  40. self.pointLabel.textColor=[UIColor colorWithHexString:@"#4A4A4A"];
  41. self.pointLabel.font=[UIFont systemFontOfSize:13];
  42. [self.hotView addSubview:self.pointLabel];
  43. }
  44. return self;
  45. }
  46. -(void)setPoint_good:(NSString *)point_good
  47. {
  48. _point_good = point_good;
  49. self.pointLabel.text=point_good;
  50. CGFloat height =[KDPublicMethod getHeightByWidth:SCREEN_WIDTH-40 title:point_good font:[UIFont systemFontOfSize:13]];
  51. self.hotView.frame=CGRectMake(10, 0, SCREEN_WIDTH-20, 45+height);
  52. self.pointLabel.frame=CGRectMake(10,28, SCREEN_WIDTH-40, 10+height);
  53. }
  54. #pragma mark---复制
  55. -(void)copyclickButton
  56. {
  57. UIPasteboard * pastboard = [UIPasteboard generalPasteboard];
  58. if (self.point_good) {
  59. pastboard.string =self.point_good;
  60. [MBProgressHUD showMessage:@"复制成功"];
  61. }else {
  62. [MBProgressHUD showMessage:@"复制失败"];
  63. }
  64. }
  65. @end