猎豆优选

LDUpdatePopView.m 2.9KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. //
  2. // LDUpdatePopView.m
  3. // YouHuiProject
  4. //
  5. // Created by 小花 on 2018/5/9.
  6. // Copyright © 2018年 kuxuan. All rights reserved.
  7. //
  8. #import "LDUpdatePopView.h"
  9. @implementation LDUpdatePopView
  10. - (instancetype)initWithFrame:(CGRect)frame searchText:(NSString *)searchText isNeed:(BOOL)isNeed{
  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 isNeed:isNeed];
  17. }
  18. return self;
  19. }
  20. - (void)initSubViewWithText:(NSString *)searchText isNeed:(BOOL)isNeed{
  21. UIImageView *imageView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, self.width, Fitsize(85))];
  22. imageView.image = [UIImage imageNamed:@"update_top"];
  23. [self addSubview:imageView];
  24. UILabel *desLb = [[UILabel alloc] initWithFrame:CGRectMake(0, imageView.bottom+10, self.width, 17)];
  25. desLb.text = @"猎豆优选的小伙伴们,我们有新功能啦";
  26. desLb.font = [UIFont systemFontOfSize:14];
  27. desLb.textAlignment = NSTextAlignmentCenter;
  28. desLb.textColor = [UIColor YHColorWithHex:0x666666];
  29. [self addSubview:desLb];
  30. UILabel *searchLabel = [[UILabel alloc] initWithFrame:CGRectMake(23, imageView.bottom+20, self.width-46, 70)];
  31. searchLabel.numberOfLines = 3;
  32. searchLabel.textColor = [UIColor YHColorWithHex:0x262626];
  33. searchLabel.textAlignment = NSTextAlignmentCenter;
  34. searchLabel.font = [UIFont systemFontOfSize:14];
  35. searchLabel.text = [searchText isKindOfClass:[NSNull class]]?@"":searchText;
  36. [self addSubview:searchLabel];
  37. UIButton *cancelBtn = [[UIButton alloc] initWithFrame:CGRectMake(0, self.height-57, self.width/2, 57)];
  38. [cancelBtn setTitleColor:[UIColor YHColorWithHex:0x999999] forState:UIControlStateNormal];
  39. [cancelBtn setTitle:@"以后再说" forState:UIControlStateNormal];
  40. cancelBtn.titleLabel.font = [UIFont systemFontOfSize:16];
  41. [cancelBtn addTarget:self action:@selector(cancelAction) forControlEvents:UIControlEventTouchUpInside];
  42. [self addSubview:cancelBtn];
  43. UIButton *searchBtn = [[UIButton alloc] initWithFrame:CGRectMake(self.width/2, self.height-57, self.width/2, 57)];
  44. [searchBtn setTitleColor:[UIColor homeRedColor] forState:UIControlStateNormal];
  45. [searchBtn setTitle:@"马上升级" forState:UIControlStateNormal];
  46. searchBtn.titleLabel.font = [UIFont systemFontOfSize:16];
  47. [searchBtn addTarget:self action:@selector(searchClick) forControlEvents:UIControlEventTouchUpInside];
  48. [self addSubview:searchBtn];
  49. if (isNeed) {
  50. cancelBtn.hidden = YES;
  51. searchBtn.x = 0;
  52. searchBtn.width = self.width;
  53. }
  54. }
  55. - (void)cancelAction {
  56. if (self.cancelClick) {
  57. self.cancelClick();
  58. }
  59. }
  60. - (void)searchClick {
  61. if (self.updateClick) {
  62. self.updateClick();
  63. }
  64. }
  65. @end