口袋优选

KBFindNavBarView.m 3.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. //
  2. // KBFindNavBarView.m
  3. // YouHuiProject
  4. //
  5. // Created by xiaoxi on 2018/1/19.
  6. // Copyright © 2018年 kuxuan. All rights reserved.
  7. //
  8. #import "KBFindNavBarView.h"
  9. @implementation KBFindNavBarView
  10. - (instancetype)initWithFrame:(CGRect)frame {
  11. self = [super initWithFrame:frame];
  12. if (self) {
  13. self.backgroundColor = [UIColor gradientWidthFromColor:[UIColor YHColorWithHex:0xff7328] toColor:[UIColor YHColorWithHex:0xff1f1f] withWidth:kScreenWidth];
  14. [self initSubviews];
  15. }
  16. return self;
  17. }
  18. - (void)initSubviews {
  19. [self addSubview:self.leftLabel];
  20. [self addSubview:self.rightButton];
  21. [self addSubview:self.bottomButton];
  22. [self.leftLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  23. make.left.equalTo(self).offset(FITSIZE(15));
  24. make.top.equalTo(self).offset(FITSIZE(58));
  25. }];
  26. [self.rightButton mas_makeConstraints:^(MASConstraintMaker *make) {
  27. make.right.equalTo(self).offset(-FITSIZE(15));
  28. make.top.equalTo(self).offset(FITSIZE(55));
  29. make.size.mas_equalTo(CGSizeMake(FITSIZE(110), FITSIZE(26)));
  30. }];
  31. [self.bottomButton mas_makeConstraints:^(MASConstraintMaker *make) {
  32. make.left.equalTo(self).offset(FITSIZE(15));
  33. make.bottom.equalTo(self).offset(-FITSIZE(12));
  34. make.right.equalTo(self).offset(-FITSIZE(15));
  35. make.height.mas_equalTo(FITSIZE(36));
  36. }];
  37. }
  38. - (void)helpButtonAction {
  39. if ([self.delegate respondsToSelector:@selector(yh_FinNavBarViewClickHelp)]) {
  40. [self.delegate yh_FinNavBarViewClickHelp];
  41. }
  42. }
  43. - (void)searchButtonAction {
  44. if ([self.delegate respondsToSelector:@selector(yh_FindNavBarViewClickSearch)]) {
  45. [self.delegate yh_FindNavBarViewClickSearch];
  46. }
  47. }
  48. #pragma mark - lazy
  49. - (UILabel *)leftLabel {
  50. if (!_leftLabel) {
  51. _leftLabel = [[UILabel alloc] init];
  52. _leftLabel.backgroundColor = [UIColor clearColor];
  53. _leftLabel.textColor = [UIColor whiteColor];
  54. _leftLabel.font = [UIFont systemFontOfSize:FITSIZE(20)];
  55. }
  56. return _leftLabel;
  57. }
  58. - (UIButton *)rightButton {
  59. if (!_rightButton) {
  60. _rightButton = [UIButton buttonWithType:UIButtonTypeCustom];
  61. _rightButton.backgroundColor = [UIColor clearColor];
  62. _rightButton.layer.cornerRadius = FITSIZE(13);
  63. _rightButton.layer.borderColor = [UIColor whiteColor].CGColor;
  64. _rightButton.layer.borderWidth = 1;
  65. [_rightButton setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
  66. [_rightButton setTitle:@"淘宝查券指南" forState:UIControlStateNormal];
  67. [_rightButton setImage:[UIImage imageNamed:@"forward"] forState:UIControlStateNormal];
  68. _rightButton.titleLabel.font = [UIFont systemFontOfSize:FITSIZE(12)];
  69. [_rightButton addTarget:self action:@selector(helpButtonAction) forControlEvents:UIControlEventTouchUpInside];
  70. [_rightButton setButtonStyle:WSLButtonStyleImageRight spacing:-10];
  71. }
  72. return _rightButton;
  73. }
  74. - (UIButton *)bottomButton {
  75. if (!_bottomButton) {
  76. _bottomButton = [UIButton buttonWithType:UIButtonTypeCustom];
  77. _bottomButton.backgroundColor = [[UIColor whiteColor] colorWithAlphaComponent:0.3];
  78. [_bottomButton setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
  79. [_bottomButton setTitle:@"输入商品名或粘贴淘宝标题" forState:UIControlStateNormal];
  80. [_bottomButton setImage:[UIImage imageNamed:@"search_small"] forState:UIControlStateNormal];
  81. _bottomButton.titleLabel.font = [UIFont systemFontOfSize:FITSIZE(14)];
  82. [_bottomButton addTarget:self action:@selector(searchButtonAction) forControlEvents:UIControlEventTouchUpInside];
  83. [_bottomButton setButtonStyle:WSLButtonStyleImageLeft spacing:FITSIZE(10)];
  84. }
  85. return _bottomButton;
  86. }
  87. @end