admin
2023-04-21 0b3a4aaf99ea251bc8e27b96115288f0988fcffe
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
//
//  PPTVNavView.m
//  BuWanVideo2.0
//
//  Created by Aeline on 2021/5/15.
//  Copyright © 2021 com.yeshi.buwansheque.ios. All rights reserved.
//
 
#import "PPTVNavView.h"
 
@interface PPTVNavView ()
@property (nonatomic, nullable, strong) UIView *viewBG;
@property (nonatomic, nullable, strong) UIButton *buttonBack;
@property (nonatomic, nullable, strong) UIButton *buutonRight;
@property (nonatomic, nullable, strong) UILabel *labelTitle;
@property (nonatomic, nullable, strong) UILabel *labelContent;
@end
 
@implementation PPTVNavView
 
- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        self.backgroundColor = [UIColor whiteColor];
        [self setupViewConfig];
    }
    return self;
}
 
- (void)setupViewConfig {
    [self addSubview:self.viewBG];
    [self.viewBG addSubview:self.buttonBack];
    [self.viewBG addSubview:self.buutonRight];
    [self.viewBG addSubview:self.labelTitle];
    [self.viewBG addSubview:self.labelContent];
    
    self.viewBG.sd_layout.leftSpaceToView(self, 0).topSpaceToView(self, kStatusBarH).rightSpaceToView(self, 0).bottomSpaceToView(self, 0);
    self.buttonBack.sd_layout.leftSpaceToView(self.viewBG, 10).centerYEqualToView(self.viewBG).widthIs(30).heightIs(30);
    self.buutonRight.sd_layout.rightSpaceToView(self.viewBG, 10).centerYEqualToView(self.viewBG).widthIs(30).heightIs(30);
    
    self.labelTitle.sd_layout.leftSpaceToView(self.buttonBack, 10).topSpaceToView(self.viewBG, 3).rightSpaceToView(self.buutonRight, 0).autoHeightRatio(0);
    self.labelContent.sd_layout.leftSpaceToView(self.buttonBack, 10).topSpaceToView(self.labelTitle, -3).rightSpaceToView(self.buutonRight, 0).widthIs(KScreenW - 90);
}
 
- (void)back {
    if (_delegate && [_delegate respondsToSelector:@selector(backVc)]) {
        [_delegate backVc];
    }
}
 
- (void)more {
    if (_delegate && [_delegate respondsToSelector:@selector(moreSelect)]) {
        [_delegate moreSelect];
    }
}
 
- (void)setName:(NSString *)name {
    self.labelTitle.text = name;
}
 
- (void)setContent:(NSString *)content {
    self.labelContent.text = content;
}
 
- (UIView *)viewBG {
    if (!_viewBG) {
        _viewBG = [[UIView alloc] init];
    }
    return _viewBG;
}
 
- (UIButton *)buttonBack {
    if (!_buttonBack) {
        _buttonBack = [UIButton buttonWithType:UIButtonTypeCustom];
        [_buttonBack setImage:[UIImage imageNamed:@"详情页面返回"] forState:UIControlStateNormal];
        [_buttonBack addTarget:self action:@selector(back) forControlEvents:UIControlEventTouchUpInside];
    }
    return _buttonBack;
}
 
- (UIButton *)buutonRight {
    if (!_buutonRight) {
        _buutonRight = [UIButton buttonWithType:UIButtonTypeCustom];
        [_buutonRight setImage:[UIImage imageNamed:@"pptv_more"] forState:UIControlStateNormal];
        [_buutonRight addTarget:self action:@selector(more) forControlEvents:UIControlEventTouchUpInside];
    }
    return _buutonRight;
}
 
- (UILabel *)labelTitle {
    if (!_labelTitle) {
        _labelTitle = [[UILabel alloc] init];
        _labelTitle.font = [UIFont systemFontOfSize:17];
        _labelTitle.textColor =UIColorFromRGBValue(0x000000);
        _labelTitle.textAlignment = NSTextAlignmentLeft;
    }
    return _labelTitle;
}
 
- (UILabel *)labelContent {
    if (!_labelContent) {
        _labelContent = [[UILabel alloc] init];
        _labelContent.font = [UIFont systemFontOfSize:10];
        _labelContent.textColor =UIColorFromRGBValue(0x999999);
        _labelContent.textAlignment = NSTextAlignmentLeft;
    }
    return _labelContent;
}
@end