线上所有马甲包模板,与《猎豆》同UI。域名zhuadd

HSQGoodDetailBottomView.m 4.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  1. //
  2. // HSQGoodDetailBottomView.m
  3. // YouHuiProject
  4. //
  5. // Created by xiaoxi on 2018/1/25.
  6. // Copyright © 2018年 kuxuan. All rights reserved.
  7. //
  8. #import "HSQGoodDetailBottomView.h"
  9. #import "HSQGoodDetailModel.h"
  10. @interface HSQGoodDetailBottomView ()
  11. @end
  12. @implementation HSQGoodDetailBottomView
  13. - (instancetype)initWithFrame:(CGRect)frame {
  14. self = [super initWithFrame:frame];
  15. if (self) {
  16. self.backgroundColor=[UIColor colorWithRed:255/255.0 green:255/255.0 blue:255/255.0 alpha:1.0];
  17. [self initSubviews];
  18. }
  19. return self;
  20. }
  21. - (void)initSubviews {
  22. [self addSubview:self.buyButton];
  23. // [self addSubview:self.commissionButton];
  24. self.commissionButton.frame=CGRectMake(FITSIZE(10), FITSIZE(8), (SCREEN_WIDTH-Fitsize(20))/2, FITSIZE(39));
  25. self.buyButton.frame=CGRectMake(FITSIZE(10), FITSIZE(8), (SCREEN_WIDTH-Fitsize(20)), FITSIZE(40));
  26. [_commissionButton setTitle:@"分享赚钱" forState:UIControlStateNormal];
  27. [_buyButton setTitle:@"领券购买" forState:UIControlStateNormal];
  28. // // 设置圆角
  29. // UIBezierPath *maskPath = [UIBezierPath bezierPathWithRoundedRect:self.buyButton.bounds byRoundingCorners:UIRectCornerBottomRight | UIRectCornerTopRight cornerRadii:CGSizeMake(FITSIZE(19.5), FITSIZE(19.5))];
  30. //
  31. // CAShapeLayer *maskLayer = [[CAShapeLayer alloc] init];
  32. // maskLayer.frame = self.buyButton.bounds;
  33. // maskLayer.path = maskPath.CGPath;
  34. self.buyButton.layer.cornerRadius = Fitsize(20);
  35. self.buyButton.layer.masksToBounds = YES;
  36. // self.buyButton.layer.mask = maskLayer;
  37. // 设置圆角
  38. UIBezierPath *maskPath1 = [UIBezierPath bezierPathWithRoundedRect:self.commissionButton.bounds byRoundingCorners:UIRectCornerBottomLeft | UIRectCornerTopLeft cornerRadii:CGSizeMake(FITSIZE(19.5), FITSIZE(19.5))];
  39. CAShapeLayer *maskLayer1 = [[CAShapeLayer alloc] init];
  40. maskLayer1.frame = self.commissionButton.bounds;
  41. maskLayer1.path = maskPath1.CGPath;
  42. self.commissionButton.layer.mask = maskLayer1;
  43. }
  44. - (void)setGoodModel:(HSQGoodDetailModel *)goodModel {
  45. _goodModel = goodModel;
  46. }
  47. - (void)buttonAction:(UIButton *)sender {
  48. //
  49. switch (sender.tag) {
  50. case 1:
  51. {
  52. if ([self.delegate respondsToSelector:@selector(yh_GoodDetailBottomViewClickCollectButton)]) {
  53. [self.delegate yh_GoodDetailBottomViewClickCollectButton];
  54. }
  55. }
  56. break;
  57. case 2:
  58. {
  59. if ([self.delegate respondsToSelector:@selector(yh_GoodDetailBottomViewClickCommissionButton)]) {
  60. [self.delegate yh_GoodDetailBottomViewClickCommissionButton];
  61. }
  62. }
  63. break;
  64. case 3:
  65. {
  66. if ([self.delegate respondsToSelector:@selector(yh_GoodDetailBottomViewClickBuyButton)]) {
  67. [self.delegate yh_GoodDetailBottomViewClickBuyButton];
  68. }
  69. }
  70. break;
  71. default:
  72. break;
  73. }
  74. }
  75. #pragma mark - lazy
  76. - (UIButton *)buyButton {
  77. if (!_buyButton) {
  78. _buyButton = [UIButton buttonWithType:UIButtonTypeCustom];
  79. _buyButton.backgroundColor = [UIColor YHColorWithHex:0xFA2C36];
  80. _buyButton.titleLabel.numberOfLines = 1;
  81. _buyButton.titleLabel.textAlignment = NSTextAlignmentCenter;
  82. _buyButton.tag = 3;
  83. [_buyButton addTarget:self action:@selector(buttonAction:) forControlEvents:UIControlEventTouchUpInside];
  84. _buyButton.titleLabel.font = [UIFont boldSystemFontOfSize:14];
  85. [_buyButton setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
  86. [_buyButton setImage:[UIImage imageNamed:@"quan-2"] forState:UIControlStateNormal];
  87. [_buyButton setImageEdgeInsets:UIEdgeInsetsMake(FITSIZE(10), FITSIZE(43), FITSIZE(9), (SCREEN_WIDTH-Fitsize(20))/2-FITSIZE(67))];
  88. }
  89. return _buyButton;
  90. }
  91. - (UIButton *)commissionButton {
  92. if (!_commissionButton) {
  93. _commissionButton = [UIButton buttonWithType:UIButtonTypeCustom];
  94. _commissionButton.backgroundColor = [UIColor gradientWidthFromColor:[UIColor YHColorWithHex:0xFEC800] toColor:[UIColor YHColorWithHex:0xFD9D03] withWidth:(SCREEN_WIDTH-Fitsize(18))/2];
  95. _commissionButton.titleLabel.textAlignment = NSTextAlignmentCenter;
  96. _commissionButton.tag = 2;
  97. [_commissionButton addTarget:self action:@selector(buttonAction:) forControlEvents:UIControlEventTouchUpInside];
  98. _commissionButton.titleLabel.font = [UIFont boldSystemFontOfSize:14];
  99. [_commissionButton setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
  100. [_commissionButton setImage:[UIImage imageNamed:@"fenxiang-3"] forState:UIControlStateNormal];
  101. [_commissionButton setImageEdgeInsets:UIEdgeInsetsMake(FITSIZE(10), FITSIZE(43), FITSIZE(9), (SCREEN_WIDTH-Fitsize(20))/2-FITSIZE(67))];
  102. }
  103. return _commissionButton;
  104. }
  105. @end