123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899 |
- //
- // KDPSuppltContentReusableView.m
- // KuDianProject
- //
- // Created by admin on 2019/7/4.
- // Copyright © 2019 KDP. All rights reserved.
- //
- #import "KDPSupplyContentReusableView.h"
- @implementation KDPSupplyContentReusableView
- {
- UIButton *_priceBtn;
- UIView *_lineView;
- UIButton *_profitBtn;
- }
- - (instancetype)initWithFrame:(CGRect)frame{
- if (self = [super initWithFrame:frame]) {
- [self setContentView];
- [self setContentConstraints];
- }
- return self;
- }
- - (void)setContentView{
- self.backgroundColor = [UIColor whiteColor];
-
- _priceBtn = [UIButton buttonWithType:UIButtonTypeCustom];
- [_priceBtn setImage:[UIImage imageNamed:@"shaixuan_icon"] forState:UIControlStateNormal];
- [_priceBtn setTitleColor:[UIColor colorWithRGB:0x333333] forState:UIControlStateNormal];
- [_priceBtn setTitle:@"价格筛选" forState:UIControlStateNormal];
- _priceBtn.titleLabel.font = FONT_SYS(15);
- [_priceBtn setButtonStyle:WSLButtonStyleImageRight spacing:6];
- _priceBtn.tag = 2000;
- [_priceBtn addTarget:self action:@selector(buttonClick:) forControlEvents:UIControlEventTouchUpInside];
- [self addSubview:_priceBtn];
-
- _lineView = [[UIView alloc] init];
- _lineView.backgroundColor = [UIColor colorWithRGB:0xDEDDDD];
- [self addSubview:_lineView];
-
- _profitBtn = [UIButton buttonWithType:UIButtonTypeCustom];
- [_profitBtn setImage:[UIImage imageNamed:@"shaixuan_icon"] forState:UIControlStateNormal];
- [_profitBtn setTitleColor:[UIColor colorWithRGB:0x333333] forState:UIControlStateNormal];
- [_profitBtn setTitle:@"利润筛选" forState:UIControlStateNormal];
- _profitBtn.titleLabel.font = FONT_SYS(15);
- [_profitBtn setButtonStyle:WSLButtonStyleImageRight spacing:6];
- _profitBtn.tag = 3000;
- [_profitBtn addTarget:self action:@selector(buttonClick:) forControlEvents:UIControlEventTouchUpInside];
- [self addSubview:_profitBtn];
-
- }
- - (void)setContentConstraints{
- [_lineView mas_makeConstraints:^(MASConstraintMaker *make) {
- make.top.equalTo(self.mas_top).offset(6);
- make.bottom.equalTo(self.mas_bottom).offset(-6);
- make.width.equalTo(1);
- make.centerX.equalTo(self);
- }];
- [_priceBtn mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.top.bottom.equalTo(self);
- make.right.equalTo(self->_lineView.mas_left);
- }];
- [_profitBtn mas_makeConstraints:^(MASConstraintMaker *make) {
- make.right.top.bottom.equalTo(self);
- make.left.equalTo(self->_lineView.mas_right);
- }];
- }
- - (void)buttonClick:(UIButton *)sender{
- if (sender.tag == 2000) { // 价格
- if (self.changeBlock) {
- self.changeBlock(YES);
- }
- } else{ // 利润
- if (self.changeBlock) {
- self.changeBlock(NO);
- }
- }
- }
- - (void)changeScreeWithStyle:(KDPSupplyContentButtonStyle)style Color:(UIColor *)color text:(NSString *)text{
- if (style == KDPSupplyContentButtonStylePrice) {
- [_priceBtn setTitleColor:color forState:UIControlStateNormal];
- [_priceBtn setTitle:text forState:UIControlStateNormal];
- NSString *imageName = [text isEqualToString:@"价格筛选"] ? @"shaixuan_icon" : @"";
- [_priceBtn setImage:[UIImage imageNamed:imageName] forState:UIControlStateNormal];
- } else{
- [_profitBtn setTitleColor:color forState:UIControlStateNormal];
- [_profitBtn setTitle:text forState:UIControlStateNormal];
- NSString *imageName = [text isEqualToString:@"利润筛选"] ? @"shaixuan_icon" : @"";
- [_profitBtn setImage:[UIImage imageNamed:imageName] forState:UIControlStateNormal];
- }
- }
- @end
|