Commit 33df79eec3bf4746aaa61afd14526728e9abff5a

Authored by zhangxiaowen
1 parent 4d1ebc9c

no message

Showing 15 changed files with 53 additions and 14 deletions
CNLiveCustomControl/Assets/NavigationBar/NavigationBar.xcassets/mine_back_black_b.imageset/Contents.json renamed to CNLiveCustomControl/Assets/NavigationBar/NavigationBar.xcassets/cnlive_back_black_b.imageset/Contents.json
... ... @@ -6,12 +6,12 @@
6 6 },
7 7 {
8 8 "idiom" : "universal",
9   - "filename" : "mine_back_black_b@2x.png",
  9 + "filename" : "cnlive_back_black_b@2x.png",
10 10 "scale" : "2x"
11 11 },
12 12 {
13 13 "idiom" : "universal",
14   - "filename" : "mine_back_black_b@3x.png",
  14 + "filename" : "cnlive_back_black_b@3x.png",
15 15 "scale" : "3x"
16 16 }
17 17 ],
... ...
CNLiveCustomControl/Assets/NavigationBar/NavigationBar.xcassets/mine_back_black_b.imageset/mine_back_black_b@2x.png renamed to CNLiveCustomControl/Assets/NavigationBar/NavigationBar.xcassets/cnlive_back_black_b.imageset/cnlive_back_black_b@2x.png

1.49 KB

CNLiveCustomControl/Assets/NavigationBar/NavigationBar.xcassets/mine_back_black_b.imageset/mine_back_black_b@3x.png renamed to CNLiveCustomControl/Assets/NavigationBar/NavigationBar.xcassets/cnlive_back_black_b.imageset/cnlive_back_black_b@3x.png

1.79 KB

CNLiveCustomControl/Assets/NavigationBar/NavigationBar.xcassets/mine_back_white_b.imageset/Contents.json renamed to CNLiveCustomControl/Assets/NavigationBar/NavigationBar.xcassets/cnlive_back_white_b.imageset/Contents.json
... ... @@ -6,12 +6,12 @@
6 6 },
7 7 {
8 8 "idiom" : "universal",
9   - "filename" : "mine_back_white_b@2x.png",
  9 + "filename" : "cnlive_back_white_b@2x.png",
10 10 "scale" : "2x"
11 11 },
12 12 {
13 13 "idiom" : "universal",
14   - "filename" : "mine_back_white_b@3x.png",
  14 + "filename" : "cnlive_back_white_b@3x.png",
15 15 "scale" : "3x"
16 16 }
17 17 ],
... ...
CNLiveCustomControl/Assets/NavigationBar/NavigationBar.xcassets/mine_back_white_b.imageset/mine_back_white_b@2x.png renamed to CNLiveCustomControl/Assets/NavigationBar/NavigationBar.xcassets/cnlive_back_white_b.imageset/cnlive_back_white_b@2x.png

2.03 KB

CNLiveCustomControl/Assets/NavigationBar/NavigationBar.xcassets/mine_back_white_b.imageset/mine_back_white_b@3x.png renamed to CNLiveCustomControl/Assets/NavigationBar/NavigationBar.xcassets/cnlive_back_white_b.imageset/cnlive_back_white_b@3x.png

2.28 KB

CNLiveCustomControl/Assets/NavigationBar/NavigationBar.xcassets/mine_code_more.imageset/Contents.json renamed to CNLiveCustomControl/Assets/NavigationBar/NavigationBar.xcassets/cnlive_black_more.imageset/Contents.json
... ... @@ -6,12 +6,12 @@
6 6 },
7 7 {
8 8 "idiom" : "universal",
9   - "filename" : "mine_code_more@2x.png",
  9 + "filename" : "cnlive_black_more@2x.png",
10 10 "scale" : "2x"
11 11 },
12 12 {
13 13 "idiom" : "universal",
14   - "filename" : "mine_code_more@3x.png",
  14 + "filename" : "cnlive_black_more@3x.png",
15 15 "scale" : "3x"
16 16 }
17 17 ],
... ...
CNLiveCustomControl/Assets/NavigationBar/NavigationBar.xcassets/mine_info_set.imageset/mine_info_set@2x.png renamed to CNLiveCustomControl/Assets/NavigationBar/NavigationBar.xcassets/cnlive_black_more.imageset/cnlive_black_more@2x.png

238 Bytes

CNLiveCustomControl/Assets/NavigationBar/NavigationBar.xcassets/mine_info_set.imageset/mine_info_set@3x.png renamed to CNLiveCustomControl/Assets/NavigationBar/NavigationBar.xcassets/cnlive_black_more.imageset/cnlive_black_more@3x.png

434 Bytes

CNLiveCustomControl/Assets/NavigationBar/NavigationBar.xcassets/mine_info_set.imageset/Contents.json renamed to CNLiveCustomControl/Assets/NavigationBar/NavigationBar.xcassets/cnlive_white_more.imageset/Contents.json
... ... @@ -6,12 +6,12 @@
6 6 },
7 7 {
8 8 "idiom" : "universal",
9   - "filename" : "mine_info_set@2x.png",
  9 + "filename" : "cnlive_white_more@2x.png",
10 10 "scale" : "2x"
11 11 },
12 12 {
13 13 "idiom" : "universal",
14   - "filename" : "mine_info_set@3x.png",
  14 + "filename" : "cnlive_white_more@3x.png",
15 15 "scale" : "3x"
16 16 }
17 17 ],
... ...
CNLiveCustomControl/Assets/NavigationBar/NavigationBar.xcassets/mine_code_more.imageset/mine_code_more@2x.png renamed to CNLiveCustomControl/Assets/NavigationBar/NavigationBar.xcassets/cnlive_white_more.imageset/cnlive_white_more@2x.png

205 Bytes

CNLiveCustomControl/Assets/NavigationBar/NavigationBar.xcassets/mine_code_more.imageset/mine_code_more@3x.png renamed to CNLiveCustomControl/Assets/NavigationBar/NavigationBar.xcassets/cnlive_white_more.imageset/cnlive_white_more@3x.png

962 Bytes

CNLiveCustomControl/Classes/NavigationBar/CNLiveNavigationBar.h
... ... @@ -17,15 +17,23 @@ NS_ASSUME_NONNULL_BEGIN
17 17  
18 18 // 左边按钮
19 19 @property (nonatomic, strong) UIButton *left;
  20 +// 左边按钮图片
  21 +@property (nonatomic, strong) UIImage *leftImage;
  22 +// 左边按钮文字
  23 +@property (nonatomic, copy) NSString *leftTitle;
20 24  
21 25 // 标题
22 26 @property (nonatomic, strong) UILabel *title;
23 27  
  28 +// 右边按钮
  29 +@property (nonatomic, strong) UIButton *right;
24 30 // 右边按钮图片
25 31 @property (nonatomic, strong) UIImage *rightImage;
26 32 // 右边按钮文字
27 33 @property (nonatomic, copy) NSString *rightTitle;
28 34  
  35 +// 线是否隐藏
  36 +@property (nonatomic, assign) BOOL lineHidden;
29 37  
30 38 + (instancetype)navigationBar;
31 39  
... ...
CNLiveCustomControl/Classes/NavigationBar/CNLiveNavigationBar.m
... ... @@ -12,7 +12,7 @@
12 12  
13 13 @interface CNLiveNavigationBar ()
14 14 @property (nonatomic, strong) UIView *navView;
15   -@property (nonatomic, strong) UIButton *right;
  15 +@property (nonatomic, strong) UIView *line;
16 16  
17 17 @end
18 18  
... ... @@ -51,9 +51,28 @@ static const NSInteger margin = 15;
51 51 [self addSubview:self.left];
52 52 [self addSubview:self.title];
53 53 [self addSubview:self.right];
  54 + [self addSubview:self.line];
  55 +
54 56 }
55 57  
56 58 #pragma mark - Setter方法
  59 +- (void)setLeftTitle:(NSString *)leftTitle{
  60 + _leftTitle = leftTitle;
  61 + if(leftTitle&&![leftTitle isEqualToString:@""]){
  62 + _left.hidden = NO;
  63 + [_left setTitle:leftTitle forState:UIControlStateNormal];
  64 + }
  65 +
  66 +}
  67 +
  68 +- (void)setLeftImage:(UIImage *)leftImage{
  69 + _leftImage = leftImage;
  70 + if(leftImage){
  71 + _left.hidden = NO;
  72 + [_left setImage:leftImage forState:UIControlStateNormal];
  73 + }
  74 +
  75 +}
57 76 - (void)setRightTitle:(NSString *)rightTitle{
58 77 _rightTitle = rightTitle;
59 78 if(rightTitle&&![rightTitle isEqualToString:@""]){
... ... @@ -72,6 +91,11 @@ static const NSInteger margin = 15;
72 91  
73 92 }
74 93  
  94 +- (void)setLineHidden:(BOOL)lineHidden{
  95 + _lineHidden = lineHidden;
  96 + _line.hidden = lineHidden;
  97 +}
  98 +
75 99 /*
76 100 // Only override drawRect: if you perform custom drawing.
77 101 // An empty implementation adversely affects performance during animation.
... ... @@ -107,7 +131,7 @@ static const NSInteger margin = 15;
107 131 _left= [UIButton buttonWithType:UIButtonTypeCustom];
108 132 _left.adjustsImageWhenHighlighted = NO;
109 133 _left.frame = CGRectMake(margin, StatusBarHeight, NavigationBarHeight, NavigationBarHeight);
110   - UIImage *image = [self getImageWithImageName:@"mine_back_black_b" bundleName:@"CNLiveCustomControl" targetClass:[self class]];
  134 + UIImage *image = [self getImageWithImageName:@"cnlive_back_black_b" bundleName:@"CNLiveCustomControl" targetClass:[self class]];
111 135 [_left setImage:[image imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal] forState:UIControlStateNormal];
112 136 _left.titleLabel.font = [UIFont systemFontOfSize:15];
113 137 [_left setContentHorizontalAlignment:UIControlContentHorizontalAlignmentLeft];
... ... @@ -140,4 +164,12 @@ static const NSInteger margin = 15;
140 164 return _right;
141 165 }
142 166  
  167 +- (UIView *)line {
  168 + if (!_line) {
  169 + _line = [[UIView alloc] initWithFrame:CGRectMake(0, NavigationContentTop-0.5, SCREEN_WIDTH, 0.5)];
  170 + _line.backgroundColor = [UIColor colorWithRed:(CGFloat)(218.0/255.0) green:(CGFloat)(218.0/255.0) blue:(CGFloat)(218.0/255.0) alpha:1.0];
  171 + }
  172 + return _line;
  173 +}
  174 +
143 175 @end
... ...
Example/CNLiveCustomControl/CNLIVEViewController.m
... ... @@ -25,6 +25,8 @@
25 25 {
26 26 [super viewDidLoad];
27 27 // Do any additional setup after loading the view, typically from a nib.
  28 + self.view.backgroundColor = [UIColor redColor];
  29 +
28 30 [self.view addSubview:self.navigationBar];
29 31  
30 32 }
... ... @@ -34,15 +36,12 @@
34 36 [super didReceiveMemoryWarning];
35 37 // Dispose of any resources that can be recreated.
36 38 }
37   -- (void)navigationBar:(CNLiveNavigationBar *)navigationBar actionEvents:(NSString *)actionEvents{
38   - NSLog(@"%@",actionEvents);
39   -
40   -}
41 39  
42 40 - (CNLiveNavigationBar *)navigationBar {
43 41 if (!_navigationBar) {
44 42 _navigationBar = [CNLiveNavigationBar navigationBar];
45 43 _navigationBar.title.text = @"首页";
  44 + _navigationBar.backgroundColor = [UIColor clearColor];
46 45 // _navigationBar.rightTitle = @"相册";
47 46 _navigationBar.onClickLeftButton = ^{
48 47 NSLog(@"左");
... ...