猎豆优选

LDSearchPopView.m 2.9KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. //
  2. // LDSearchPopView.m
  3. // YouHuiProject
  4. //
  5. // Created by 小花 on 2018/5/9.
  6. // Copyright © 2018年 kuxuan. All rights reserved.
  7. //
  8. #import "LDSearchPopView.h"
  9. @implementation LDSearchPopView
  10. - (instancetype)initWithFrame:(CGRect)frame searchText:(NSString *)searchText{
  11. self = [super initWithFrame:frame];
  12. if (self) {
  13. self.layer.cornerRadius = 6;
  14. self.layer.masksToBounds = YES;
  15. self.backgroundColor = [UIColor whiteColor];
  16. [self initSubViewWithText:searchText];
  17. }
  18. return self;
  19. }
  20. - (void)initSubViewWithText:(NSString *)searchText {
  21. UIImageView *imageView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, self.width, Fitsize(85))];
  22. imageView.image = [UIImage imageNamed:@"SearchPop_bg"];
  23. [self addSubview:imageView];
  24. UILabel *titleLb = [[UILabel alloc] initWithFrame:CGRectMake(0, Fitsize(20), self.width, 25)];
  25. titleLb.text = @"智能省钱";
  26. titleLb.font = [UIFont systemFontOfSize:16];
  27. titleLb.textAlignment = NSTextAlignmentCenter;
  28. titleLb.textColor = [UIColor whiteColor];
  29. [imageView addSubview:titleLb];
  30. UILabel *desLb = [[UILabel alloc] initWithFrame:CGRectMake(0, titleLb.bottom, self.width, 17)];
  31. desLb.text = @"您可能想搜索该商品";
  32. desLb.font = [UIFont systemFontOfSize:12];
  33. desLb.textAlignment = NSTextAlignmentCenter;
  34. desLb.textColor = [UIColor whiteColor];
  35. [imageView addSubview:desLb];
  36. UILabel *searchLabel = [[UILabel alloc] initWithFrame:CGRectMake(23, imageView.bottom+30, self.width-46, 60)];
  37. searchLabel.numberOfLines = 3;
  38. searchLabel.textColor = [UIColor YHColorWithHex:0x262626];
  39. searchLabel.textAlignment = NSTextAlignmentCenter;
  40. searchLabel.font = [UIFont systemFontOfSize:14];
  41. searchLabel.text = searchText;
  42. [self addSubview:searchLabel];
  43. UIButton *cancelBtn = [[UIButton alloc] initWithFrame:CGRectMake(0, self.height-57, self.width/2, 57)];
  44. [cancelBtn setTitleColor:[UIColor YHColorWithHex:0x999999] forState:UIControlStateNormal];
  45. [cancelBtn setTitle:@"取消" forState:UIControlStateNormal];
  46. cancelBtn.titleLabel.font = [UIFont systemFontOfSize:16];
  47. [cancelBtn addTarget:self action:@selector(cancelAction) forControlEvents:UIControlEventTouchUpInside];
  48. [self addSubview:cancelBtn];
  49. UIButton *searchBtn = [[UIButton alloc] initWithFrame:CGRectMake(self.width/2, self.height-57, self.width/2, 57)];
  50. [searchBtn setTitleColor:[UIColor homeRedColor] forState:UIControlStateNormal];
  51. [searchBtn setTitle:@"搜索" forState:UIControlStateNormal];
  52. searchBtn.titleLabel.font = [UIFont systemFontOfSize:16];
  53. [searchBtn addTarget:self action:@selector(searchClick) forControlEvents:UIControlEventTouchUpInside];
  54. [self addSubview:searchBtn];
  55. }
  56. - (void)cancelAction {
  57. if (self.cancelClick) {
  58. self.cancelClick();
  59. }
  60. }
  61. - (void)searchClick {
  62. if (self.searchlClick) {
  63. self.searchlClick();
  64. }
  65. }
  66. @end