You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
129 lines
4.3 KiB
129 lines
4.3 KiB
4 years ago
|
//
|
||
|
// TFComicBrowseTopBar.m
|
||
|
// TFReader
|
||
|
//
|
||
|
// Created by 谢腾飞 on 2020/12/16.
|
||
|
// Copyright © 2020 xtfei_2011@126.com. All rights reserved.
|
||
|
//
|
||
|
|
||
|
#import "TFComicBrowseTopBar.h"
|
||
|
|
||
|
@interface TFComicBrowseTopBar ()
|
||
|
{
|
||
|
UILabel *navTitleLabel;
|
||
|
}
|
||
|
@end
|
||
|
|
||
|
@implementation TFComicBrowseTopBar
|
||
|
|
||
|
- (instancetype)init
|
||
|
{
|
||
|
if (self = [super init]) {
|
||
|
self.frame = CGRectMake(0, - PUB_NAVBAR_HEIGHT, SCREEN_WIDTH, PUB_NAVBAR_HEIGHT);
|
||
|
[self createSubViews];
|
||
|
}
|
||
|
return self;
|
||
|
}
|
||
|
|
||
|
- (void)createSubViews
|
||
|
{
|
||
|
self.backgroundColor = kWhiteColor;
|
||
|
|
||
|
// 默认左侧显示返回按钮
|
||
|
UIButton *leftBackButton = [UIButton buttonWithType:UIButtonTypeCustom];
|
||
|
leftBackButton.backgroundColor = [UIColor clearColor];
|
||
|
[leftBackButton.titleLabel setFont:kMainFont];
|
||
|
leftBackButton.adjustsImageWhenHighlighted = NO;
|
||
|
[leftBackButton setImage:[[UIImage imageNamed:@"public_back"] imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate] forState:UIControlStateNormal];
|
||
|
[leftBackButton setImageEdgeInsets:UIEdgeInsetsMake(12, 6, 12, 18)];
|
||
|
[leftBackButton setTitleColor:[UIColor grayColor] forState:UIControlStateNormal];
|
||
|
[leftBackButton setTintColor:kBlackColor];
|
||
|
[leftBackButton addTarget:self action:@selector(leftBack) forControlEvents:UIControlEventTouchUpInside];
|
||
|
[self addSubview:leftBackButton];
|
||
|
|
||
|
[leftBackButton mas_makeConstraints:^(MASConstraintMaker *make) {
|
||
|
make.left.mas_equalTo(kHalfMargin);
|
||
|
make.bottom.mas_equalTo(self.bottom);
|
||
|
make.width.mas_equalTo(44);
|
||
|
make.height.mas_equalTo(44);
|
||
|
}];
|
||
|
|
||
|
navTitleLabel = [[UILabel alloc] init];
|
||
|
navTitleLabel.backgroundColor = [UIColor clearColor];
|
||
|
navTitleLabel.textColor = [UIColor blackColor];
|
||
|
navTitleLabel.numberOfLines = 1;
|
||
|
navTitleLabel.font = kFont16;
|
||
|
navTitleLabel.textAlignment = NSTextAlignmentCenter;
|
||
|
[self addSubview:navTitleLabel];
|
||
|
|
||
|
[navTitleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
|
||
|
make.centerY.mas_equalTo(leftBackButton.mas_centerY);
|
||
|
make.height.mas_equalTo(20);
|
||
|
make.left.equalTo(leftBackButton.mas_right).offset(kHalfMargin);
|
||
|
}];
|
||
|
|
||
|
UIButton *completeButton = [UIButton buttonWithType:UIButtonTypeCustom];
|
||
|
completeButton.backgroundColor = [UIColor clearColor];
|
||
|
completeButton.adjustsImageWhenHighlighted = NO;
|
||
|
[completeButton setTitleColor:kMainColor forState:UIControlStateNormal];
|
||
|
[completeButton setTitle:TFLocalizedString(@"全集") forState:UIControlStateNormal];
|
||
|
[completeButton.titleLabel setFont:kMainFont];
|
||
|
[completeButton addTarget:self action:@selector(completeButtonClick) forControlEvents:UIControlEventTouchUpInside];
|
||
|
[self addSubview:completeButton];
|
||
|
|
||
|
[navTitleLabel mas_updateConstraints:^(MASConstraintMaker *make) {
|
||
|
make.right.equalTo(completeButton.mas_left).offset(-kHalfMargin);
|
||
|
}];
|
||
|
|
||
|
[completeButton mas_makeConstraints:^(MASConstraintMaker *make) {
|
||
|
make.right.mas_equalTo(self.mas_right).with.offset(- kHalfMargin);
|
||
|
make.bottom.mas_equalTo(self.bottom);
|
||
|
make.width.mas_equalTo(completeButton.intrinsicContentSize.width);
|
||
|
make.height.mas_equalTo(44);
|
||
|
}];
|
||
|
|
||
|
UIImageView *navBottomLine = [[UIImageView alloc] init];
|
||
|
navBottomLine.userInteractionEnabled = YES;
|
||
|
navBottomLine.image = [UIImage imageNamed:@"navbar_bottom_line"];
|
||
|
[self addSubview:navBottomLine];
|
||
|
|
||
|
[navBottomLine mas_makeConstraints:^(MASConstraintMaker *make) {
|
||
|
make.left.mas_equalTo(0);
|
||
|
make.top.mas_equalTo(self.mas_bottom);
|
||
|
make.width.mas_equalTo(self.mas_width);
|
||
|
make.height.mas_equalTo(1);
|
||
|
}];
|
||
|
|
||
|
}
|
||
|
|
||
|
- (void)showMenuTopBar
|
||
|
{
|
||
|
[UIView animateWithDuration:kAnimatedDurationFast animations:^{
|
||
|
self.frame = CGRectMake(0, 0, SCREEN_WIDTH, PUB_NAVBAR_HEIGHT);
|
||
|
}];
|
||
|
}
|
||
|
|
||
|
- (void)hiddenMenuTopBar
|
||
|
{
|
||
|
[UIView animateWithDuration:kAnimatedDurationFast animations:^{
|
||
|
self.frame = CGRectMake(0, - PUB_NAVBAR_HEIGHT, SCREEN_WIDTH, PUB_NAVBAR_HEIGHT);
|
||
|
}];
|
||
|
}
|
||
|
|
||
|
- (void)setNavTitle:(NSString *)titleString
|
||
|
{
|
||
|
navTitleLabel.text = titleString?:@"";
|
||
|
}
|
||
|
|
||
|
- (void)leftBack
|
||
|
{
|
||
|
[[NSNotificationCenter defaultCenter] postNotificationName:Notification_Pop_Comic_Reader object:nil];
|
||
|
}
|
||
|
|
||
|
- (void)completeButtonClick
|
||
|
{
|
||
|
[[NSNotificationCenter defaultCenter] postNotificationName:Notification_Push_To_Directory object:nil];
|
||
|
}
|
||
|
|
||
|
@end
|