萤石云 iOSSDK,移植跨平台相关工程
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
//
//  TopBarView.m
//Ezviz
//
//  Created by 陈启扬 on 2022/3/23.
//
 
#import "HDLEZTopBarView.h"
 
@interface HDLEZTopBarView()
 
 
@end
 
@implementation HDLEZTopBarView
 
- (id)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        self.frame = CGRectMake(0, 0, HDLEZ_APP_SCREEN_WIDTH, HDLEZ_APP_TOP_BAR_HEIGHT);
        self.backgroundColor=HDLEZ_COLOR_NAV_BACKGROUND;
        [self addSubview:self.backButton];
        [self addSubview:self.titleLabel];
        [self addSubview:self.bottomLine];
        [self addSubview:self.rightButton];
        [self addSubview:self.leftButton];
        [self.rightButton setHidden:YES];
        [self.leftButton setHidden:YES];
        [self.bottomLine setHidden:YES];
    }
    return self;
}
 
- (UIButton*)backButton{
    if(!_backButton){
        //buttonWithType UIButtonTypeSystem 设置tintColor 就可以改变图片的颜色
        _backButton = [HDLEZButton buttonWithType:UIButtonTypeSystem];
        _backButton.frame = CGRectMake(16, HDLEZ_APP_STATUS_BAR_HEIGHT+(44-20)/2, 12, 20);
        [_backButton setImage:[UIImage imageNamed:@"hdl_ez_ic_nav_back"] forState:UIControlStateNormal];
        _backButton.tapHeight=40;
        _backButton.tapWidth=80;
 
        //按钮图标颜色
        _backButton.tintColor = HDLEZ_COLOR_TEXT;
    }
    return _backButton;
}
 
/*左边按钮
 */
-(UIButton*)leftButton{
    if(!_leftButton){
        //buttonWithType UIButtonTypeSystem 设置tintColor 就可以改变图片的颜色
        _leftButton = [HDLEZButton buttonWithType:UIButtonTypeSystem];
        _leftButton.frame = CGRectMake(16, HDLEZ_APP_STATUS_BAR_HEIGHT+(44-20)/2, 80, 20);
        [_leftButton setTitleColor:HDLEZ_COLOR_TEXT_TITLE_GRAY forState:UIControlStateNormal];
        _leftButton.titleLabel.font=HDLEZ_Get_FontRegularWithSize(HDLEZ_FontSize_14);
        _leftButton.contentHorizontalAlignment = UIControlContentHorizontalAlignmentLeft;
        _leftButton.tapHeight=40;
        _leftButton.tapWidth=80;
    }
    return _leftButton;
}
 
- (UILabel *)titleLabel{
    if (!_titleLabel) {
        _titleLabel = [self NewLabel:CGRectMake(40, HDLEZ_APP_STATUS_BAR_HEIGHT, HDLEZ_APP_SCREEN_WIDTH - 80, 44) font:HDLEZ_Get_FontRegularWithSize(HDLEZ_FontSize_18) textColor:HDLEZ_COLOR_TEXT text:@""];
        _titleLabel.textAlignment = NSTextAlignmentCenter;
    }
    return _titleLabel;
}
 
- (UIView *)bottomLine{
    if (!_bottomLine) {
        _bottomLine = [[UIView alloc] initWithFrame:CGRectMake(0, HDLEZ_APP_TOP_BAR_HEIGHT, HDLEZ_APP_SCREEN_WIDTH, 0.5)];
//        _bottomLine.backgroundColor=HDLFVRGBCOLOR(191, 192, 194,1.0);
        _bottomLine.backgroundColor=HDLEZ_COLOR_TEXT;
 
    }
    return _bottomLine;
}
 
- (UIButton*)rightButton{
    if(!_rightButton){
        //buttonWithType UIButtonTypeSystem 设置tintColor 就可以改变图片的颜色
//        _rightButton = [UIButton buttonWithType:UIButtonTypeSystem];
        _rightButton=[[HDLEZButton alloc] init];
        _rightButton.frame = CGRectMake(HDLEZ_APP_SCREEN_WIDTH-12-32, HDLEZ_APP_STATUS_BAR_HEIGHT+(44-32)/2, 32, 32);
        [_rightButton setTitleColor:HDLEZ_COLOR_TEXT_LIGHT_BLUE forState:UIControlStateNormal];
        _rightButton.titleLabel.font=HDLEZ_Get_FontRegularWithSize(HDLEZ_FontSize_14);
        _rightButton.tapHeight=44;
        _rightButton.tapWidth=44;
 
        //按钮图标颜色
//        _backButton.tintColor = HDLEZ_COLOR_TEXT;
    }
    return _rightButton;
}
//
-(void)backButtonClick{
    
}
 
-(void)setTitle:(NSString *)title{
    self.titleLabel.text = title;
}
 
-(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)setLeftBtnTitle:(NSString *)leftBtnTitle{
    _leftBtnTitle=leftBtnTitle;
    [_leftButton setHidden:NO];
    [_leftButton setTitle:leftBtnTitle forState:UIControlStateNormal];
}
/*设置右边按钮标题
 */
-(void)setRightBtnTitle:(NSString *)rightBtnTitle{
    _rightBtnTitle=rightBtnTitle;
    [_rightButton setHidden:NO];
    [_rightButton setTitle:rightBtnTitle forState:UIControlStateNormal];
}
 
@end