123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132 |
- //
- // ToolsBarView.m
- // jiaPei
- //
- // Created by 张嵘 on 2019/8/29.
- // Copyright © 2019 JCZ. All rights reserved.
- //
- #import "ToolsBarView.h"
- @interface ToolsBarView ()
- @property (strong, readwrite, nonatomic) UIButton *rightBtn;
- @property (strong, readwrite, nonatomic) UIButton *errorBtn;
- @end
- @implementation ToolsBarView
- - (instancetype)initWithFrame:(CGRect)frame {
- self = [super initWithFrame:frame];
- if (self) {
- [self setup];
- }
- return self;
- }
- - (void)setup {
- self.backgroundColor = UIColor.whiteColor;
- [self addSubview:self.collectBtn];
- [self addSubview:self.rightBtn];
- [self addSubview:self.errorBtn];
- [self addSubview:self.listBtn];
- }
- - (void)layoutSubviews {
- [super layoutSubviews];
- [self.collectBtn mas_makeConstraints:^(MASConstraintMaker *make) {
- make.centerY.mas_equalTo(self);
- make.left.mas_offset(8);
- make.size.mas_equalTo(CGSizeMake(75, self.bounds.size.height));
- }];
-
- [self.rightBtn mas_makeConstraints:^(MASConstraintMaker *make) {
- make.centerX.mas_offset(-25);
- make.centerY.mas_equalTo(self);
- make.size.mas_equalTo(CGSizeMake(50, self.bounds.size.height));
- }];
-
- [self.errorBtn mas_makeConstraints:^(MASConstraintMaker *make) {
- make.centerX.mas_offset(25);
- make.centerY.mas_equalTo(self);
- make.size.mas_equalTo(CGSizeMake(50, self.bounds.size.height));
- }];
-
- [self.listBtn mas_makeConstraints:^(MASConstraintMaker *make) {
- make.centerY.mas_equalTo(self);
- make.right.mas_offset(-8);
- make.size.mas_equalTo(CGSizeMake(80, self.bounds.size.height));
- }];
- }
- #pragma mark - HWPanModalIndicatorProtocol
- - (void)didChangeToState:(HWIndicatorState)state {
- }
- - (CGSize)indicatorSize {
- return CGSizeMake(kScreenWidth, 44);
- }
- - (void)setupSubviews {
-
- }
- - (void)collectAction {
- self.collectBtn.selected = !self.collectBtn.selected;
- }
- #pragma mark - LazyLoad
- - (UIButton *)listBtn {
- if (!_listBtn) {
- _listBtn = [UIButton buttonWithType:UIButtonTypeCustom];
- [_listBtn setImage:[UIImage imageNamed:@"icon_exercise_board_v6"] forState:UIControlStateNormal];
- [_listBtn setTitleNormal:@"0/500"];
- [_listBtn setTitleColor:UIColor.blackColor forState:UIControlStateNormal];
- _listBtn.titleEdgeInsets = UIEdgeInsetsMake(0, 8, 0, 0);
- _listBtn.titleLabel.font = [UIFont systemFontOfSize:14];
- }
- return _listBtn;
- }
- - (UIButton *)collectBtn {
- if (!_collectBtn) {
- _collectBtn = [UIButton buttonWithType:UIButtonTypeCustom];
- [_collectBtn setImage:[UIImage imageNamed:@"icon_examin_shoucang"] forState:UIControlStateNormal];
- [_collectBtn setImage:[UIImage imageNamed:@"icon_examin_shoucang2"] forState:UIControlStateSelected];
- [_collectBtn setTitleNormal:@"收藏"];
- [_collectBtn setTitleSelect:@"已收藏"];
- [_collectBtn setTitleColor:UIColor.blackColor forState:UIControlStateNormal];
- _collectBtn.titleEdgeInsets = UIEdgeInsetsMake(0, 8, 0, 0);
- _collectBtn.titleLabel.font = [UIFont systemFontOfSize:14];
- [_collectBtn addTarget:self action:@selector(collectAction) forControlEvents:UIControlEventTouchUpInside];
- }
- return _collectBtn;
- }
- - (UIButton *)rightBtn {
- if (!_rightBtn) {
- _rightBtn = [UIButton buttonWithType:UIButtonTypeCustom];
- [_rightBtn setImage:[UIImage imageNamed:@"icon_question_right"] forState:UIControlStateNormal];
- [_rightBtn setTitleNormal:@"0"];
- [_rightBtn setTitleColor:[UIColor colorWithRed:0.36 green:0.75 blue:0.51 alpha:1.00] forState:UIControlStateNormal];
- _rightBtn.titleEdgeInsets = UIEdgeInsetsMake(0, 8, 0, 0);
- _rightBtn.titleLabel.font = [UIFont systemFontOfSize:14];
- _rightBtn.userInteractionEnabled = NO;
- }
- return _rightBtn;
- }
- - (UIButton *)errorBtn {
- if (!_errorBtn) {
- _errorBtn = [UIButton buttonWithType:UIButtonTypeCustom];
- [_errorBtn setImage:[UIImage imageNamed:@"icon_question_wrong4"] forState:UIControlStateNormal];
- [_errorBtn setTitleNormal:@"0"];
- [_errorBtn setTitleColor:[UIColor colorWithRed:0.92 green:0.46 blue:0.36 alpha:1.00] forState:UIControlStateNormal];
- _errorBtn.titleEdgeInsets = UIEdgeInsetsMake(0, 8, 0, 0);
- _errorBtn.titleLabel.font = [UIFont systemFontOfSize:14];
- _errorBtn.userInteractionEnabled = NO;
- }
- return _errorBtn;
- }
- @end
|