Commit bd65dd5289c098a092a88888b67b602147d3a8d8

Authored by zhangxiaowen
1 parent c94c6e13

no message

CNLiveMineModule/Classes/Controller/CNLiveMineController.m
... ... @@ -11,22 +11,28 @@
11 11 #import "MJExtension.h"
12 12 #import "QMUIKit.h"
13 13  
  14 +#import "CNLiveMineNavigationBar.h"
14 15 #import "CNLiveMineHeaderView.h"
15 16 #import "CNLiveMineCell.h"
16 17 #import "CNLiveMineModel.h"
17 18  
18 19 #define HexColor(rgbValue) [UIColor colorWithRed:((float)((rgbValue & 0xFF0000) >> 16))/255.0 green:((float)((rgbValue & 0xFF00) >> 8))/255.0 blue:((float)(rgbValue & 0xFF))/255.0 alpha:1.0]
19 20  
20   -@interface CNLiveMineController()<UITableViewDelegate, UITableViewDataSource, CNLiveMineHeaderViewDelegate, CNLiveMineCellDelegate>
  21 +@interface CNLiveMineController()<UITableViewDelegate, UITableViewDataSource, CNLiveMineHeaderViewDelegate, CNLiveMineCellDelegate>{
  22 + CGFloat beginContentY;
  23 + CGFloat endContentY;
  24 +
  25 +}
21 26 @property (nonatomic, strong) UITableView *tableView;
22 27 @property (nonatomic, weak) CNLiveMineHeaderView *headerView;
  28 +@property (nonatomic, strong) CNLiveMineNavigationBar *navigationBar;
23 29 @property (nonatomic, strong) UIButton *soccerBtn;
24 30 @property (nonatomic, strong) NSMutableArray *data;
25 31  
26 32 @end
27 33  
28 34 @implementation CNLiveMineController
29   -static const NSInteger kHEIGHT = 240;
  35 +static const NSInteger kHEIGHT = 250;
30 36  
31 37 #pragma mark - 加载数据
32 38 - (void)loadData {
... ... @@ -110,6 +116,7 @@ static const NSInteger kHEIGHT = 240;
110 116 headerView.tag = 666;
111 117 [self.tableView addSubview:headerView];
112 118 self.headerView = headerView;
  119 + [self.view addSubview:self.navigationBar];
113 120 [self.view addSubview:self.soccerBtn];
114 121 }
115 122  
... ... @@ -170,7 +177,6 @@ static const NSInteger kHEIGHT = 240;
170 177 rect.origin.y = point.y;
171 178 rect.size.height = -point.y;
172 179 [self.tableView viewWithTag:666].frame = rect;
173   - NSLog(@"%f",point.y);
174 180 if(point.y < -320){
175 181 // XWWitnessController *vc = [[XWWitnessController alloc]init];
176 182 // CATransition *transition = [CATransition animation];
... ... @@ -185,7 +191,20 @@ static const NSInteger kHEIGHT = 240;
185 191 }
186 192 }
187 193  
  194 + if (point.y > -200) {
  195 + [UIView animateWithDuration:0.25 animations:^{
  196 + self.navigationBar.frame = CGRectMake(0, 0, SCREEN_WIDTH, NavigationContentTop);
  197 + }];
  198 +
  199 + } else {
  200 + [UIView animateWithDuration:0.25 animations:^{
  201 + self.navigationBar.frame = CGRectMake(0, -NavigationContentTop, SCREEN_WIDTH, NavigationContentTop);
  202 + }];
  203 +
  204 + }
  205 +
188 206 }
  207 +
189 208 #pragma mark - CNLiveMineCellDelegate
190 209 - (void)cell:(CNLiveMineCell *)cell clickedButtonWithType:(CNLiveMineCellType)type tag:(NSInteger)tag{
191 210 switch (type) {
... ... @@ -275,6 +294,13 @@ static const NSInteger kHEIGHT = 240;
275 294 }
276 295 return _data;
277 296 }
  297 +- (CNLiveMineNavigationBar *)navigationBar {
  298 + if (!_navigationBar) {
  299 + _navigationBar = [[CNLiveMineNavigationBar alloc]initWithFrame:CGRectMake(0, -NavigationContentTop, SCREEN_WIDTH, NavigationContentTop)];
  300 + _navigationBar.backgroundColor = [UIColor colorWithRed:32/255.0 green:31/255.0 blue:36/255.0 alpha:1.0];
  301 + }
  302 + return _navigationBar;
  303 +}
278 304  
279 305 - (UITableView *)tableView{
280 306 if(!_tableView){
... ...
CNLiveMineModule/Classes/View/CNLiveMineHeaderView.m
... ... @@ -104,7 +104,7 @@ static const NSInteger margin = 20;
104 104 [_certification mas_remakeConstraints:^(MASConstraintMaker *make) {
105 105 make.centerY.equalTo(self.header.mas_centerY);
106 106 make.left.equalTo(self.header.mas_right).with.offset(margin/2.0);
107   - make.height.offset(30);
  107 + make.height.offset(35);
108 108  
109 109 }];
110 110  
... ... @@ -269,7 +269,7 @@ static const NSInteger margin = 20;
269 269 _address.numberOfLines = 1;
270 270 _address.textColor = [UIColor colorWithRed:140/255.0 green:140/255.0 blue:142/255.0 alpha:1.0];
271 271 _address.font = [UIFont systemFontOfSize:14];
272   - _address.attributedText = [self createAttributedImageName:@"mine_location" string:@"北京" isFront:YES];
  272 + _address.attributedText = [self createAttributedImageName:@"mine_location" string:@"北京海淀区花园桥" isFront:YES];
273 273 }
274 274 return _address;
275 275 }
... ...
CNLiveMineModule/Classes/View/CNLiveMineNavigationBar.h 0 → 100644
  1 +//
  2 +// CNLiveMineNavigationBar.h
  3 +// CNLiveMineModule
  4 +//
  5 +// Created by 153993236@qq.com on 11/12/2019.
  6 +// Copyright © 2019 153993236@qq.com. All rights reserved.
  7 +//
  8 +
  9 +#import <UIKit/UIKit.h>
  10 +
  11 +NS_ASSUME_NONNULL_BEGIN
  12 +
  13 +@interface CNLiveMineNavigationBar : UIView
  14 +
  15 +
  16 +@end
  17 +
  18 +NS_ASSUME_NONNULL_END
... ...
CNLiveMineModule/Classes/View/CNLiveMineNavigationBar.m 0 → 100644
  1 +//
  2 +// CNLiveMineNavigationBar.m
  3 +// CNLiveMineModule
  4 +//
  5 +// Created by 153993236@qq.com on 11/12/2019.
  6 +// Copyright © 2019 153993236@qq.com. All rights reserved.
  7 +//
  8 +
  9 +#import "CNLiveMineNavigationBar.h"
  10 +#import <Masonry/Masonry.h>
  11 +#import <SDWebImage/SDWebImage.h>
  12 +#import "QMUIKit.h"
  13 +#import "CNUserInfoManager.h"
  14 +
  15 +#define HexColor(rgbValue) [UIColor colorWithRed:((float)((rgbValue & 0xFF0000) >> 16))/255.0 green:((float)((rgbValue & 0xFF00) >> 8))/255.0 blue:((float)(rgbValue & 0xFF))/255.0 alpha:1.0]
  16 +
  17 +@interface CNLiveMineNavigationBar ()
  18 +@property (nonatomic, strong) UIImageView *header;
  19 +@property (nonatomic, strong) UILabel *name;
  20 +
  21 +@end
  22 +
  23 +@implementation CNLiveMineNavigationBar
  24 +static const NSInteger margin = 10;
  25 +
  26 +- (instancetype)initWithFrame:(CGRect)frame{
  27 + self = [super initWithFrame:frame];
  28 + if(self){
  29 + self.userInteractionEnabled = YES;
  30 + self.backgroundColor = [UIColor clearColor];
  31 + [self createSubViews];
  32 + }
  33 + return self;
  34 +}
  35 +
  36 +
  37 +- (void)dealloc {
  38 + NSLog(@"CNLiveMineNavigationBar -- dealloc");
  39 +}
  40 +
  41 +- (void)createSubViews {
  42 + [self addSubview:self.header];
  43 + [self addSubview:self.name];
  44 +}
  45 +
  46 +- (void)layoutSubviews{
  47 + [super layoutSubviews];
  48 +
  49 + NSDictionary *dic = @{NSFontAttributeName:[UIFont systemFontOfSize:14]};
  50 + CGFloat width = [@"张晓文" boundingRectWithSize:CGSizeMake(0, 0) options:NSStringDrawingUsesLineFragmentOrigin | NSStringDrawingUsesFontLeading attributes:dic context:nil].size.width+margin;
  51 +
  52 + [_name mas_makeConstraints:^(MASConstraintMaker *make) {
  53 + make.left.equalTo(self.mas_left).with.offset((SCREEN_WIDTH-width)/2.0+30);
  54 + make.top.equalTo(self.mas_top).with.offset(StatusBarHeight);
  55 + make.bottom.equalTo(self.mas_bottom).with.offset(-0);
  56 + make.width.offset(width);
  57 +
  58 + }];
  59 +
  60 + [_header mas_makeConstraints:^(MASConstraintMaker *make) {
  61 + make.right.equalTo(self.name.mas_left).with.offset(-margin);
  62 + make.top.equalTo(self.mas_top).with.offset((NavigationBarHeight-30)/2.0+StatusBarHeight);
  63 + make.width.height.offset(30);
  64 +
  65 + }];
  66 +}
  67 +/*
  68 + // Only override drawRect: if you perform custom drawing.
  69 + // An empty implementation adversely affects performance during animation.
  70 + - (void)drawRect:(CGRect)rect {
  71 + // Drawing code
  72 + }
  73 + */
  74 +
  75 +#pragma mark - 懒加载
  76 +- (UIImageView *)header {
  77 + if (!_header) {
  78 + _header = [[UIImageView alloc] init];
  79 + _header.userInteractionEnabled = YES;
  80 + _header.layer.masksToBounds = YES;
  81 + _header.layer.cornerRadius = 15;
  82 + UIImage *xw_image = [self xw_getImageName:@"default_avatar_y" bundleName:@"CNLiveMineModule" targetClass:[CNLiveMineNavigationBar class]];
  83 + [_header sd_setImageWithURL:[NSURL URLWithString:@"头像"] placeholderImage:xw_image];
  84 +
  85 + }
  86 + return _header;
  87 +}
  88 +
  89 +- (UILabel *)name {
  90 + if (!_name) {
  91 + _name = [[UILabel alloc] init];
  92 + _name.userInteractionEnabled = YES;
  93 + _name.numberOfLines = 1;
  94 + _name.textColor = [UIColor whiteColor];
  95 + _name.font = [UIFont systemFontOfSize:14];
  96 + _name.text = CNUserShareModel.nickname;
  97 + _name.text = @"张晓文";
  98 + }
  99 + return _name;
  100 +}
  101 +
  102 +/**
  103 + * 创建图片
  104 + *
  105 + * @param imageName 图片名字
  106 + * @param bundleName 图片所在的bundle名字
  107 + * @param targetClass 类和bundle的同级目录
  108 + * @return 返回UIImage
  109 + */
  110 +- (UIImage *)xw_getImageName:(NSString *)imageName bundleName:(NSString *)bundleName targetClass:(Class)targetClass{
  111 + NSBundle *bundle = [NSBundle bundleForClass:targetClass];
  112 + NSURL *url = [bundle URLForResource:bundleName withExtension:@"bundle"];
  113 + NSBundle *targetBundle = [NSBundle bundleWithURL:url];
  114 + UIImage *image = [UIImage imageNamed:imageName inBundle:targetBundle compatibleWithTraitCollection:nil];
  115 + return image?image:[UIImage imageNamed:imageName inBundle:[NSBundle mainBundle] compatibleWithTraitCollection:nil];
  116 +
  117 +}
  118 +
  119 +@end
... ...