ToolsBarView.m 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  1. //
  2. // ToolsBarView.m
  3. // jiaPei
  4. //
  5. // Created by 张嵘 on 2019/8/29.
  6. // Copyright © 2019 JCZ. All rights reserved.
  7. //
  8. #import "ToolsBarView.h"
  9. @interface ToolsBarView ()
  10. @property (strong, readwrite, nonatomic) UIButton *rightBtn;
  11. @property (strong, readwrite, nonatomic) UIButton *errorBtn;
  12. @end
  13. @implementation ToolsBarView
  14. - (instancetype)initWithFrame:(CGRect)frame {
  15. self = [super initWithFrame:frame];
  16. if (self) {
  17. [self setup];
  18. }
  19. return self;
  20. }
  21. - (void)setup {
  22. self.backgroundColor = UIColor.whiteColor;
  23. [self addSubview:self.collectBtn];
  24. [self addSubview:self.rightBtn];
  25. [self addSubview:self.errorBtn];
  26. [self addSubview:self.listBtn];
  27. }
  28. - (void)layoutSubviews {
  29. [super layoutSubviews];
  30. [self.collectBtn mas_makeConstraints:^(MASConstraintMaker *make) {
  31. make.centerY.mas_equalTo(self);
  32. make.left.mas_offset(8);
  33. make.size.mas_equalTo(CGSizeMake(75, self.bounds.size.height));
  34. }];
  35. [self.rightBtn mas_makeConstraints:^(MASConstraintMaker *make) {
  36. make.centerX.mas_offset(-25);
  37. make.centerY.mas_equalTo(self);
  38. make.size.mas_equalTo(CGSizeMake(50, self.bounds.size.height));
  39. }];
  40. [self.errorBtn mas_makeConstraints:^(MASConstraintMaker *make) {
  41. make.centerX.mas_offset(25);
  42. make.centerY.mas_equalTo(self);
  43. make.size.mas_equalTo(CGSizeMake(50, self.bounds.size.height));
  44. }];
  45. [self.listBtn mas_makeConstraints:^(MASConstraintMaker *make) {
  46. make.centerY.mas_equalTo(self);
  47. make.right.mas_offset(-8);
  48. make.size.mas_equalTo(CGSizeMake(80, self.bounds.size.height));
  49. }];
  50. }
  51. #pragma mark - HWPanModalIndicatorProtocol
  52. - (void)didChangeToState:(HWIndicatorState)state {
  53. }
  54. - (CGSize)indicatorSize {
  55. return CGSizeMake(kScreenWidth, 44);
  56. }
  57. - (void)setupSubviews {
  58. }
  59. - (void)collectAction {
  60. self.collectBtn.selected = !self.collectBtn.selected;
  61. }
  62. #pragma mark - LazyLoad
  63. - (UIButton *)listBtn {
  64. if (!_listBtn) {
  65. _listBtn = [UIButton buttonWithType:UIButtonTypeCustom];
  66. [_listBtn setImage:[UIImage imageNamed:@"icon_exercise_board_v6"] forState:UIControlStateNormal];
  67. [_listBtn setTitleNormal:@"0/500"];
  68. [_listBtn setTitleColor:UIColor.blackColor forState:UIControlStateNormal];
  69. _listBtn.titleEdgeInsets = UIEdgeInsetsMake(0, 8, 0, 0);
  70. _listBtn.titleLabel.font = [UIFont systemFontOfSize:14];
  71. }
  72. return _listBtn;
  73. }
  74. - (UIButton *)collectBtn {
  75. if (!_collectBtn) {
  76. _collectBtn = [UIButton buttonWithType:UIButtonTypeCustom];
  77. [_collectBtn setImage:[UIImage imageNamed:@"icon_examin_shoucang"] forState:UIControlStateNormal];
  78. [_collectBtn setImage:[UIImage imageNamed:@"icon_examin_shoucang2"] forState:UIControlStateSelected];
  79. [_collectBtn setTitleNormal:@"收藏"];
  80. [_collectBtn setTitleSelect:@"已收藏"];
  81. [_collectBtn setTitleColor:UIColor.blackColor forState:UIControlStateNormal];
  82. _collectBtn.titleEdgeInsets = UIEdgeInsetsMake(0, 8, 0, 0);
  83. _collectBtn.titleLabel.font = [UIFont systemFontOfSize:14];
  84. [_collectBtn addTarget:self action:@selector(collectAction) forControlEvents:UIControlEventTouchUpInside];
  85. }
  86. return _collectBtn;
  87. }
  88. - (UIButton *)rightBtn {
  89. if (!_rightBtn) {
  90. _rightBtn = [UIButton buttonWithType:UIButtonTypeCustom];
  91. [_rightBtn setImage:[UIImage imageNamed:@"icon_question_right"] forState:UIControlStateNormal];
  92. [_rightBtn setTitleNormal:@"0"];
  93. [_rightBtn setTitleColor:[UIColor colorWithRed:0.36 green:0.75 blue:0.51 alpha:1.00] forState:UIControlStateNormal];
  94. _rightBtn.titleEdgeInsets = UIEdgeInsetsMake(0, 8, 0, 0);
  95. _rightBtn.titleLabel.font = [UIFont systemFontOfSize:14];
  96. _rightBtn.userInteractionEnabled = NO;
  97. }
  98. return _rightBtn;
  99. }
  100. - (UIButton *)errorBtn {
  101. if (!_errorBtn) {
  102. _errorBtn = [UIButton buttonWithType:UIButtonTypeCustom];
  103. [_errorBtn setImage:[UIImage imageNamed:@"icon_question_wrong4"] forState:UIControlStateNormal];
  104. [_errorBtn setTitleNormal:@"0"];
  105. [_errorBtn setTitleColor:[UIColor colorWithRed:0.92 green:0.46 blue:0.36 alpha:1.00] forState:UIControlStateNormal];
  106. _errorBtn.titleEdgeInsets = UIEdgeInsetsMake(0, 8, 0, 0);
  107. _errorBtn.titleLabel.font = [UIFont systemFontOfSize:14];
  108. _errorBtn.userInteractionEnabled = NO;
  109. }
  110. return _errorBtn;
  111. }
  112. @end