口袋优选

KBFindNavBarStaticView.m 1.9KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. //
  2. // KBFindNavBarStaticView.m
  3. // YouHuiProject
  4. //
  5. // Created by xiaoxi on 2018/1/29.
  6. // Copyright © 2018年 kuxuan. All rights reserved.
  7. //
  8. #import "KBFindNavBarStaticView.h"
  9. @implementation KBFindNavBarStaticView
  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.searchButton];
  20. [self.searchButton mas_makeConstraints:^(MASConstraintMaker *make) {
  21. make.left.equalTo(self).offset(FITSIZE(15));
  22. make.bottom.equalTo(self).offset(-7);
  23. make.right.equalTo(self).offset(-FITSIZE(15));
  24. make.height.mas_equalTo(30);
  25. }];
  26. self.searchButton.layer.cornerRadius = 15;
  27. }
  28. - (void)searchButtonAction {
  29. if ([self.delegate respondsToSelector:@selector(yh_FindNavBarStaticViewClickSearch)]) {
  30. [self.delegate yh_FindNavBarStaticViewClickSearch];
  31. }
  32. }
  33. #pragma mark - lazy
  34. - (UIButton *)searchButton {
  35. if (!_searchButton) {
  36. _searchButton = [UIButton buttonWithType:UIButtonTypeCustom];
  37. _searchButton.backgroundColor = [UIColor YHColorWithHex:0xF5F5F5];
  38. [_searchButton setTitleColor:[UIColor YHColorWithHex:0x999999] forState:UIControlStateNormal];
  39. [_searchButton setTitle:@"输入商品名或粘贴淘宝标题" forState:UIControlStateNormal];
  40. [_searchButton setImage:[UIImage imageNamed:@"search_small"] forState:UIControlStateNormal];
  41. _searchButton.titleLabel.font = [UIFont systemFontOfSize:FITSIZE(14)];
  42. [_searchButton addTarget:self action:@selector(searchButtonAction) forControlEvents:UIControlEventTouchUpInside];
  43. [_searchButton setButtonStyle:WSLButtonStyleImageLeft spacing:FITSIZE(10)];
  44. }
  45. return _searchButton;
  46. }
  47. @end