酷店

KDPSupplyContentReusableView.m 3.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. //
  2. // KDPSuppltContentReusableView.m
  3. // KuDianProject
  4. //
  5. // Created by admin on 2019/7/4.
  6. // Copyright © 2019 KDP. All rights reserved.
  7. //
  8. #import "KDPSupplyContentReusableView.h"
  9. @implementation KDPSupplyContentReusableView
  10. {
  11. UIButton *_priceBtn;
  12. UIView *_lineView;
  13. UIButton *_profitBtn;
  14. }
  15. - (instancetype)initWithFrame:(CGRect)frame{
  16. if (self = [super initWithFrame:frame]) {
  17. [self setContentView];
  18. [self setContentConstraints];
  19. }
  20. return self;
  21. }
  22. - (void)setContentView{
  23. self.backgroundColor = [UIColor whiteColor];
  24. _priceBtn = [UIButton buttonWithType:UIButtonTypeCustom];
  25. [_priceBtn setImage:[UIImage imageNamed:@"shaixuan_icon"] forState:UIControlStateNormal];
  26. [_priceBtn setTitleColor:[UIColor colorWithRGB:0x333333] forState:UIControlStateNormal];
  27. [_priceBtn setTitle:@"价格筛选" forState:UIControlStateNormal];
  28. _priceBtn.titleLabel.font = FONT_SYS(15);
  29. [_priceBtn setButtonStyle:WSLButtonStyleImageRight spacing:6];
  30. _priceBtn.tag = 2000;
  31. [_priceBtn addTarget:self action:@selector(buttonClick:) forControlEvents:UIControlEventTouchUpInside];
  32. [self addSubview:_priceBtn];
  33. _lineView = [[UIView alloc] init];
  34. _lineView.backgroundColor = [UIColor colorWithRGB:0xDEDDDD];
  35. [self addSubview:_lineView];
  36. _profitBtn = [UIButton buttonWithType:UIButtonTypeCustom];
  37. [_profitBtn setImage:[UIImage imageNamed:@"shaixuan_icon"] forState:UIControlStateNormal];
  38. [_profitBtn setTitleColor:[UIColor colorWithRGB:0x333333] forState:UIControlStateNormal];
  39. [_profitBtn setTitle:@"利润筛选" forState:UIControlStateNormal];
  40. _profitBtn.titleLabel.font = FONT_SYS(15);
  41. [_profitBtn setButtonStyle:WSLButtonStyleImageRight spacing:6];
  42. _profitBtn.tag = 3000;
  43. [_profitBtn addTarget:self action:@selector(buttonClick:) forControlEvents:UIControlEventTouchUpInside];
  44. [self addSubview:_profitBtn];
  45. }
  46. - (void)setContentConstraints{
  47. [_lineView mas_makeConstraints:^(MASConstraintMaker *make) {
  48. make.top.equalTo(self.mas_top).offset(6);
  49. make.bottom.equalTo(self.mas_bottom).offset(-6);
  50. make.width.equalTo(1);
  51. make.centerX.equalTo(self);
  52. }];
  53. [_priceBtn mas_makeConstraints:^(MASConstraintMaker *make) {
  54. make.left.top.bottom.equalTo(self);
  55. make.right.equalTo(self->_lineView.mas_left);
  56. }];
  57. [_profitBtn mas_makeConstraints:^(MASConstraintMaker *make) {
  58. make.right.top.bottom.equalTo(self);
  59. make.left.equalTo(self->_lineView.mas_right);
  60. }];
  61. }
  62. - (void)buttonClick:(UIButton *)sender{
  63. if (sender.tag == 2000) { // 价格
  64. if (self.changeBlock) {
  65. self.changeBlock(YES);
  66. }
  67. } else{ // 利润
  68. if (self.changeBlock) {
  69. self.changeBlock(NO);
  70. }
  71. }
  72. }
  73. - (void)changeScreeWithStyle:(KDPSupplyContentButtonStyle)style Color:(UIColor *)color text:(NSString *)text{
  74. if (style == KDPSupplyContentButtonStylePrice) {
  75. [_priceBtn setTitleColor:color forState:UIControlStateNormal];
  76. [_priceBtn setTitle:text forState:UIControlStateNormal];
  77. NSString *imageName = [text isEqualToString:@"价格筛选"] ? @"shaixuan_icon" : @"";
  78. [_priceBtn setImage:[UIImage imageNamed:imageName] forState:UIControlStateNormal];
  79. } else{
  80. [_profitBtn setTitleColor:color forState:UIControlStateNormal];
  81. [_profitBtn setTitle:text forState:UIControlStateNormal];
  82. NSString *imageName = [text isEqualToString:@"利润筛选"] ? @"shaixuan_icon" : @"";
  83. [_profitBtn setImage:[UIImage imageNamed:imageName] forState:UIControlStateNormal];
  84. }
  85. }
  86. @end