//
|
// TopBarView.m
|
// HdlSmartIoT
|
//
|
// Created by 陈嘉乐 on 2021/5/18.
|
//
|
|
#import "TopBarView.h"
|
#import "HDLSceneSiri.h"
|
|
@interface TopBarView()
|
|
|
@end
|
|
@implementation TopBarView
|
|
- (id)initWithFrame:(CGRect)frame
|
{
|
self = [super initWithFrame:frame];
|
if (self) {
|
self.frame = CGRectMake(0, 0, APP_SCREEN_WIDTH, APP_TOP_BAR_HEIGHT);
|
[self addSubview:self.backButton];
|
[self addSubview:self.titleLabel];
|
}
|
return self;
|
}
|
|
- (UIButton*)backButton{
|
if(!_backButton){
|
//buttonWithType UIButtonTypeSystem 设置tintColor 就可以改变图片的颜色
|
_backButton = [UIButton buttonWithType:UIButtonTypeSystem];
|
_backButton.frame = CGRectMake(0, APP_STATUS_BAR_HEIGHT, 39, 44);
|
[_backButton setImage:[UIImage imageNamed:@"ic_nav_back"] forState:UIControlStateNormal];
|
//按钮图标颜色
|
_backButton.tintColor = COLOR_TEXT;
|
}
|
return _backButton;
|
}
|
|
- (UILabel *)titleLabel{
|
if (!_titleLabel) {
|
_titleLabel = [self NewLabel:CGRectMake(40, APP_STATUS_BAR_HEIGHT, APP_SCREEN_WIDTH - 80, 44) font:Get_FontMediumWithSize(16) textColor:COLOR_TEXT text:@""];
|
_titleLabel.textAlignment = NSTextAlignmentCenter;
|
}
|
return _titleLabel;
|
}
|
|
- (UILabel *)NewLabel:(CGRect)frame font:(UIFont *)font textColor:(UIColor *)color text:(NSString *)text{
|
UILabel *label = [[UILabel alloc] initWithFrame:frame];
|
label.backgroundColor = [UIColor clearColor];
|
label.font = font;
|
if (color != nil) {
|
label.textColor = color;
|
}
|
label.text = text;
|
|
return label;
|
}
|
|
//
|
-(void)backButtonClick{
|
|
}
|
|
-(void)setTitle:(NSString *)title{
|
self.titleLabel.text = title;
|
}
|
|
|
@end
|