cjc 6 年 前
コミット
7b963f5eff

+ 28 - 0
CAIPU.xcodeproj/project.pbxproj

@@ -58,6 +58,8 @@
58 58
 		498F3D972085E55B00BBD7B2 /* KXHTTP.m in Sources */ = {isa = PBXBuildFile; fileRef = 498F3D962085E55B00BBD7B2 /* KXHTTP.m */; };
59 59
 		498F3D9B2085E61C00BBD7B2 /* KXMD5Manager.m in Sources */ = {isa = PBXBuildFile; fileRef = 498F3D9A2085E61C00BBD7B2 /* KXMD5Manager.m */; };
60 60
 		498F3D9F2085E97500BBD7B2 /* NSString+JZExtension.m in Sources */ = {isa = PBXBuildFile; fileRef = 498F3D9E2085E97500BBD7B2 /* NSString+JZExtension.m */; };
61
+		498F3DF32088905B00BBD7B2 /* SPScrollNumLabel.m in Sources */ = {isa = PBXBuildFile; fileRef = 498F3DF22088905A00BBD7B2 /* SPScrollNumLabel.m */; };
62
+		498F3DFC208899F000BBD7B2 /* PDEmitterView.m in Sources */ = {isa = PBXBuildFile; fileRef = 498F3DFA208899EF00BBD7B2 /* PDEmitterView.m */; };
61 63
 		49EF90C32071CADC008B7187 /* CPThemeCollectionCell.m in Sources */ = {isa = PBXBuildFile; fileRef = 49EF90C22071CADC008B7187 /* CPThemeCollectionCell.m */; };
62 64
 		49EF90CE2071F8A5008B7187 /* CPHealthViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 49EF90CD2071F8A5008B7187 /* CPHealthViewController.m */; };
63 65
 		49EF90D12071FA62008B7187 /* CPFindViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 49EF90D02071FA62008B7187 /* CPFindViewController.m */; };
@@ -253,6 +255,10 @@
253 255
 		498F3D9A2085E61C00BBD7B2 /* KXMD5Manager.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = KXMD5Manager.m; sourceTree = "<group>"; };
254 256
 		498F3D9D2085E97500BBD7B2 /* NSString+JZExtension.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NSString+JZExtension.h"; sourceTree = "<group>"; };
255 257
 		498F3D9E2085E97500BBD7B2 /* NSString+JZExtension.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "NSString+JZExtension.m"; sourceTree = "<group>"; };
258
+		498F3DF12088905A00BBD7B2 /* SPScrollNumLabel.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SPScrollNumLabel.h; sourceTree = "<group>"; };
259
+		498F3DF22088905A00BBD7B2 /* SPScrollNumLabel.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SPScrollNumLabel.m; sourceTree = "<group>"; };
260
+		498F3DFA208899EF00BBD7B2 /* PDEmitterView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = PDEmitterView.m; sourceTree = "<group>"; };
261
+		498F3DFB208899EF00BBD7B2 /* PDEmitterView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PDEmitterView.h; sourceTree = "<group>"; };
256 262
 		49EF90C12071CADC008B7187 /* CPThemeCollectionCell.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = CPThemeCollectionCell.h; sourceTree = "<group>"; };
257 263
 		49EF90C22071CADC008B7187 /* CPThemeCollectionCell.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = CPThemeCollectionCell.m; sourceTree = "<group>"; };
258 264
 		49EF90CC2071F8A5008B7187 /* CPHealthViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = CPHealthViewController.h; sourceTree = "<group>"; };
@@ -654,6 +660,24 @@
654 660
 			path = nsstring;
655 661
 			sourceTree = "<group>";
656 662
 		};
663
+		498F3DF02088905A00BBD7B2 /* SPScrollNumLabel */ = {
664
+			isa = PBXGroup;
665
+			children = (
666
+				498F3DF12088905A00BBD7B2 /* SPScrollNumLabel.h */,
667
+				498F3DF22088905A00BBD7B2 /* SPScrollNumLabel.m */,
668
+			);
669
+			path = SPScrollNumLabel;
670
+			sourceTree = "<group>";
671
+		};
672
+		498F3DFD20889A0600BBD7B2 /* PDEmitterView */ = {
673
+			isa = PBXGroup;
674
+			children = (
675
+				498F3DFB208899EF00BBD7B2 /* PDEmitterView.h */,
676
+				498F3DFA208899EF00BBD7B2 /* PDEmitterView.m */,
677
+			);
678
+			path = PDEmitterView;
679
+			sourceTree = "<group>";
680
+		};
657 681
 		49EF90C42071F753008B7187 /* Find(发现) */ = {
658 682
 			isa = PBXGroup;
659 683
 			children = (
@@ -825,6 +849,8 @@
825 849
 		C4B7E2992011D1D00046C0EC /* Third(第三方) */ = {
826 850
 			isa = PBXGroup;
827 851
 			children = (
852
+				498F3DFD20889A0600BBD7B2 /* PDEmitterView */,
853
+				498F3DF02088905A00BBD7B2 /* SPScrollNumLabel */,
828 854
 				498F3D132085D0AE00BBD7B2 /* HFStretchableTableHeaderView */,
829 855
 				49EF91E520809E83008B7187 /* MLMSegmentPageView */,
830 856
 				49EF914A2073787C008B7187 /* SDCycleScrollView */,
@@ -1371,6 +1397,7 @@
1371 1397
 				497B1BE420523E0100EBB024 /* PlaceholderTextView.m in Sources */,
1372 1398
 				498F3D162085D0AE00BBD7B2 /* HFStretchableTableHeaderView.m in Sources */,
1373 1399
 				498F3D832085DE0400BBD7B2 /* JZTimeDetailModel.m in Sources */,
1400
+				498F3DFC208899F000BBD7B2 /* PDEmitterView.m in Sources */,
1374 1401
 				498F3D932085DF2F00BBD7B2 /* JZWXLoginManager.m in Sources */,
1375 1402
 				498F3D7F2085DE0400BBD7B2 /* JZNewChartTimeModel.m in Sources */,
1376 1403
 				49EF915E2073787C008B7187 /* SDCollectionViewCell.m in Sources */,
@@ -1397,6 +1424,7 @@
1397 1424
 				498F3D922085DF2F00BBD7B2 /* JZUtil.m in Sources */,
1398 1425
 				498F3D7B2085DE0400BBD7B2 /* JZChartRequest.m in Sources */,
1399 1426
 				49EF918F208054C0008B7187 /* CPHomeThemeModel.m in Sources */,
1427
+				498F3DF32088905B00BBD7B2 /* SPScrollNumLabel.m in Sources */,
1400 1428
 				497B1BE02051458700EBB024 /* CPCollectionModel.m in Sources */,
1401 1429
 				49EF916320737A6E008B7187 /* CPHealthCell.m in Sources */,
1402 1430
 				498F3D9F2085E97500BBD7B2 /* NSString+JZExtension.m in Sources */,

+ 1 - 1
CAIPU/CPHeader.h

@@ -16,7 +16,7 @@
16 16
 #define BUGLY_ID @"50d6f2e32a"
17 17
 #define SIGN_KEY @"b693013c19222873eece0526b7b85da2"  //加密秘钥
18 18
 
19
-#define KXCHANNEL_ID @"10013"
19
+#define KXCHANNEL_ID @"20000"
20 20
 
21 21
 
22 22
 //定义屏幕的宽度

+ 2 - 0
CAIPU/Main/Find(发现)/View/CPFindIconView.h

@@ -7,9 +7,11 @@
7 7
 //
8 8
 
9 9
 #import <UIKit/UIKit.h>
10
+#import "SPScrollNumLabel.h"
10 11
 
11 12
 @interface CPFindIconView : UIView
12 13
 
14
+@property (nonatomic, weak) SPScrollNumLabel *upCountLabel;
13 15
 - (void)configViewWithIcons:(NSArray *)icons upCount:(NSString *)upCount;
14 16
 
15 17
 @end

+ 22 - 6
CAIPU/Main/Find(发现)/View/CPFindIconView.m

@@ -10,7 +10,8 @@
10 10
 
11 11
 @interface CPFindIconView ()
12 12
 @property (nonatomic, strong) NSMutableArray *views;
13
-@property (nonatomic, strong) UILabel *upCountLabel;
13
+@property (nonatomic, strong) UILabel *text;
14
+
14 15
 @end
15 16
 
16 17
 @implementation CPFindIconView
@@ -43,7 +44,8 @@
43 44
         
44 45
     }
45 46
     
46
-    UILabel *label = [[UILabel alloc] init];
47
+    
48
+    SPScrollNumLabel *label = [[SPScrollNumLabel alloc] init];
47 49
     label.frame = CGRectMake(0, 0, 150, height);
48 50
     label.font = [UIFont systemFontOfSize:12];
49 51
     label.textColor = [UIColor detailTitleColor];
@@ -51,6 +53,13 @@
51 53
     self.upCountLabel = label;
52 54
     [self.views addObject:label];
53 55
     
56
+    UILabel *text = [[UILabel alloc] init];
57
+    text.frame = CGRectMake(label.width+1, 0, 150, height);
58
+    text.font = [UIFont systemFontOfSize:12];
59
+    text.textColor = [UIColor detailTitleColor];
60
+    text.text = @"人点赞";
61
+    self.text = text;
62
+    [self addSubview:text];
54 63
 }
55 64
 
56 65
 - (void)configViewWithIcons:(NSArray *)icons upCount:(NSString *)upCount {
@@ -65,14 +74,21 @@
65 74
         
66 75
         }
67 76
     }
68
-    
77
+
69 78
     CGFloat width = 24;
70 79
     CGFloat marginLeft = 8;
71
-    
80
+
72 81
     self.upCountLabel.x = (marginLeft+width)*icons.count;
73
-    self.upCountLabel.text = [NSString stringWithFormat:@"%@人点赞",upCount];
74
-    
82
+    self.upCountLabel.userInteractionEnabled = YES;
83
+    UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapAction)];
84
+    [self.upCountLabel addGestureRecognizer:tap];
85
+    self.upCountLabel.text = upCount;
75 86
     
87
+    self.text.x = CGRectGetMaxX(self.upCountLabel.frame)+1;
88
+}
89
+
90
+- (void)tapAction {
91
+    [self.upCountLabel increaseNumber:1];
76 92
 }
77 93
 
78 94
 - (NSMutableArray *)views {

+ 47 - 5
CAIPU/Main/Find(发现)/View/CPPhotoCell.m

@@ -11,8 +11,11 @@
11 11
 #import "PYPhotoBrowseView.h"
12 12
 #import "CPFindIconView.h"
13 13
 #import "CPCommonTool.h"
14
+#import "PDEmitterView.h"
14 15
 
15
-@interface CPPhotoCell ()
16
+@interface CPPhotoCell () {
17
+    BOOL animating;
18
+}
16 19
 @property (nonatomic, strong) UIView *content;
17 20
 @property (nonatomic, strong) PYPhotosView *photosView;
18 21
 @property (nonatomic, strong) UIImageView *icon;
@@ -20,6 +23,7 @@
20 23
 @property (nonatomic, strong) UILabel *timeLabel;
21 24
 @property (nonatomic, strong) UIButton *likeBtn;
22 25
 @property (nonatomic, strong) CPFindIconView *iconView;
26
+@property (nonatomic, strong) PDEmitterView *emitterVeiw;
23 27
 
24 28
 @property (nonatomic, copy) NSString *identifier;
25 29
 @end
@@ -56,11 +60,12 @@
56 60
 
57 61
 - (void)initUI {
58 62
     [self.contentView addSubview:self.content];
63
+    [self.content addSubview:self.emitterVeiw];
59 64
     [self.content addSubview:self.icon];
60 65
     [self.content addSubview:self.nickLabel];
61 66
     [self.content addSubview:self.timeLabel];
62 67
     [self.content addSubview:self.photosView];
63
-    [self.content addSubview:self.likeBtn];
68
+    [self.emitterVeiw addSubview:self.likeBtn];
64 69
     [self.content addSubview:self.iconView];
65 70
     
66 71
     [self.content mas_makeConstraints:^(MASConstraintMaker *make) {
@@ -92,18 +97,24 @@
92 97
         make.height.mas_equalTo(0);
93 98
     }];
94 99
     
95
-    [self.likeBtn mas_makeConstraints:^(MASConstraintMaker *make) {
100
+    [self.emitterVeiw mas_makeConstraints:^(MASConstraintMaker *make) {
96 101
         make.right.mas_equalTo(-10);
97 102
         make.top.mas_equalTo(self.photosView.mas_bottom).mas_offset(15).priorityHigh();;
98 103
         make.height.mas_equalTo(30);
99 104
         make.width.mas_equalTo(40);
100 105
     }];
101 106
     
107
+    
108
+    
109
+    [self.likeBtn mas_makeConstraints:^(MASConstraintMaker *make) {
110
+        make.top.bottom.left.right.mas_equalTo(self.emitterVeiw);
111
+    }];
112
+    
102 113
     [self.iconView mas_makeConstraints:^(MASConstraintMaker *make) {
103 114
         make.left.mas_equalTo(10);
104
-        make.right.mas_equalTo(self.likeBtn.mas_left).mas_offset(-10);
115
+        make.right.mas_equalTo(self.emitterVeiw.mas_left).mas_offset(-10);
105 116
         make.height.mas_equalTo(24);
106
-        make.centerY.mas_equalTo(self.likeBtn.mas_centerY);
117
+        make.centerY.mas_equalTo(self.emitterVeiw.mas_centerY);
107 118
     }];
108 119
     
109 120
     
@@ -202,12 +213,36 @@
202 213
     return _photosView;
203 214
 }
204 215
 
216
+#pragma mark ------
217
+
218
+- (void)likeAction:(UIButton *)sender {
219
+    
220
+    if (animating) return;
221
+    animating = YES;
222
+    NSString *imageName = sender.selected ? @"like_nor":@"like_sel";
223
+    [self.emitterVeiw sendUpEmitterWithImageName:imageName];
224
+    sender.selected = !sender.selected;
225
+    [self btnClickedOperations:sender];
226
+}
227
+
228
+
229
+- (void)btnClickedOperations:(UIButton *)sender {
230
+    
231
+    dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(2 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
232
+        animating = NO;
233
+    });
234
+}
235
+
236
+
237
+#pragma mark ---
238
+
205 239
 - (UIButton *)likeBtn {
206 240
     if (!_likeBtn) {
207 241
         _likeBtn = [UIButton buttonWithType:UIButtonTypeCustom];
208 242
         [_likeBtn setImage:[UIImage imageNamed:@"like_nor"] forState:UIControlStateNormal];
209 243
         [_likeBtn setImage:[UIImage imageNamed:@"like_sel"] forState:UIControlStateSelected];
210 244
         [_likeBtn setTitleColor:[UIColor redColor] forState:UIControlStateNormal];
245
+        [_likeBtn addTarget:self action:@selector(likeAction:) forControlEvents:UIControlEventTouchUpInside];
211 246
     }
212 247
     return _likeBtn;
213 248
 }
@@ -219,6 +254,13 @@
219 254
     return _iconView;
220 255
 }
221 256
 
257
+- (PDEmitterView *)emitterVeiw {
258
+    if (!_emitterVeiw) {
259
+        _emitterVeiw = [[PDEmitterView alloc] init];
260
+    }
261
+    return _emitterVeiw;
262
+}
263
+
222 264
 
223 265
 
224 266
 - (void)setSelected:(BOOL)selected animated:(BOOL)animated {

+ 40 - 6
CAIPU/Main/Find(发现)/View/CPVideoCell.m

@@ -9,8 +9,11 @@
9 9
 #import "CPVideoCell.h"
10 10
 #import "CPFindIconView.h"
11 11
 #import "CPCommonTool.h"
12
+#import "PDEmitterView.h"
12 13
 
13
-@interface CPVideoCell ()
14
+@interface CPVideoCell (){
15
+    BOOL animating;
16
+}
14 17
 @property (nonatomic, strong) UIView *content;
15 18
 @property (nonatomic, strong) UIImageView *playImg;
16 19
 @property (nonatomic, strong) UIImageView *icon;
@@ -18,6 +21,7 @@
18 21
 @property (nonatomic, strong) UILabel *timeLabel;
19 22
 @property (nonatomic, strong) UIButton *likeBtn;
20 23
 @property (nonatomic, strong) CPFindIconView *iconView;
24
+@property (nonatomic, strong) PDEmitterView *emitterVeiw;
21 25
 @end
22 26
 
23 27
 @implementation CPVideoCell
@@ -57,12 +61,13 @@
57 61
 - (void)initUI {
58 62
     
59 63
     [self.contentView addSubview:self.content];
64
+    [self.content addSubview:self.emitterVeiw];
60 65
     [self.content addSubview:self.icon];
61 66
     [self.content addSubview:self.nickLabel];
62 67
     [self.content addSubview:self.timeLabel];
63 68
     [self.content addSubview:self.videoImage];
64 69
     [self.videoImage addSubview:self.playImg];
65
-    [self.content addSubview:self.likeBtn];
70
+    [self.emitterVeiw addSubview:self.likeBtn];
66 71
     [self.content addSubview:self.iconView];
67 72
     
68 73
     [self.content mas_makeConstraints:^(MASConstraintMaker *make) {
@@ -99,19 +104,22 @@
99 104
         make.width.height.mas_equalTo(45);
100 105
         make.center.mas_equalTo(self.videoImage.center);
101 106
     }];
102
-    [self.likeBtn mas_makeConstraints:^(MASConstraintMaker *make) {
107
+    [self.emitterVeiw mas_makeConstraints:^(MASConstraintMaker *make) {
103 108
         make.right.mas_equalTo(-10);
104 109
         make.top.mas_equalTo(self.videoImage.mas_bottom).mas_offset(15);
105 110
         make.height.mas_equalTo(30);
106 111
         make.width.mas_equalTo(40);
107 112
     }];
108 113
     
114
+    [self.likeBtn mas_makeConstraints:^(MASConstraintMaker *make) {
115
+        make.top.bottom.left.right.mas_equalTo(self.emitterVeiw);
116
+    }];
109 117
     
110 118
     [self.iconView mas_makeConstraints:^(MASConstraintMaker *make) {
111 119
         make.left.mas_equalTo(10);
112
-        make.right.mas_equalTo(self.likeBtn.mas_left).mas_offset(-10);
120
+        make.right.mas_equalTo(self.emitterVeiw.mas_left).mas_offset(-10);
113 121
         make.height.mas_equalTo(24);
114
-        make.centerY.mas_equalTo(self.likeBtn.mas_centerY);
122
+        make.centerY.mas_equalTo(self.emitterVeiw.mas_centerY);
115 123
     }];
116 124
     
117 125
 }
@@ -127,6 +135,26 @@
127 135
     
128 136
 }
129 137
 
138
+#pragma mark ------
139
+
140
+- (void)likeAction:(UIButton *)sender {
141
+    
142
+    if (animating) return;
143
+    animating = YES;
144
+    NSString *imageName = sender.selected ? @"like_nor":@"like_sel";
145
+    [self.emitterVeiw sendUpEmitterWithImageName:imageName];
146
+    sender.selected = !sender.selected;
147
+    [self btnClickedOperations:sender];
148
+}
149
+
150
+
151
+- (void)btnClickedOperations:(UIButton *)sender {
152
+    
153
+    dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(2 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
154
+        animating = NO;
155
+    });
156
+}
157
+
130 158
 
131 159
 #pragma mar ------
132 160
 
@@ -208,6 +236,7 @@
208 236
         [_likeBtn setImage:[UIImage imageNamed:@"like_nor"] forState:UIControlStateNormal];
209 237
         [_likeBtn setImage:[UIImage imageNamed:@"like_sel"] forState:UIControlStateSelected];
210 238
         [_likeBtn setTitleColor:[UIColor redColor] forState:UIControlStateNormal];
239
+        [_likeBtn addTarget:self action:@selector(likeAction:) forControlEvents:UIControlEventTouchUpInside];
211 240
     }
212 241
     return _likeBtn;
213 242
 }
@@ -219,5 +248,10 @@
219 248
     return _iconView;
220 249
 }
221 250
 
222
-
251
+- (PDEmitterView *)emitterVeiw {
252
+    if (!_emitterVeiw) {
253
+        _emitterVeiw = [[PDEmitterView alloc] init];
254
+    }
255
+    return _emitterVeiw;
256
+}
223 257
 @end

+ 3 - 3
CAIPU/Main/Home(菜谱大全)/Controllers/CPHomeViewController.m

@@ -99,9 +99,9 @@ static NSString *const themeIdentifier = @"themeIdentifier";
99 99
     collectionView.mj_header = header;
100 100
     
101 101
     //上拉加载
102
-    MJRefreshAutoNormalFooter *footer=[[MJRefreshAutoNormalFooter alloc]init];
103
-    [footer setRefreshingTarget:self refreshingAction:@selector(loadMoreData)];
104
-    collectionView.mj_footer = footer;
102
+//    MJRefreshAutoNormalFooter *footer=[[MJRefreshAutoNormalFooter alloc]init];
103
+//    [footer setRefreshingTarget:self refreshingAction:@selector(loadMoreData)];
104
+//    collectionView.mj_footer = footer;
105 105
     [self.view addSubview:collectionView];
106 106
 }
107 107
 

+ 11 - 4
CAIPU/Main/More(更多)/Controllers/CPMoreViewController.m

@@ -44,6 +44,7 @@ static NSString *const cellIdentifier = @"moreCell";
44 44
 - (void)viewDidLoad {
45 45
     [super viewDidLoad];
46 46
     // Do any additional setup after loading the view.
47
+    
47 48
     self.title = @"更多";
48 49
     self.navigationController.delegate = self;
49 50
     self.navigationController.navigationBar.barTintColor = [UIColor baseColor];
@@ -66,9 +67,9 @@ static NSString *const cellIdentifier = @"moreCell";
66 67
     self.tableView.backgroundColor = [UIColor CPColorWithHex:0xf5f4f4];
67 68
     [self.view addSubview:self.tableView];
68 69
     
69
-    UIView *header = [[UIView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, 120)];
70
+    UIView *header = [[UIView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, 140)];
70 71
     header.backgroundColor = [UIColor baseColor];
71
-    self.iconView = [[UIImageView alloc] initWithFrame:CGRectMake(30, 30, 60, 60)];
72
+    self.iconView = [[UIImageView alloc] initWithFrame:CGRectMake(30, 50, 60, 60)];
72 73
     self.iconView.cornerRadius = 30;
73 74
     self.iconView.userInteractionEnabled = YES;
74 75
     self.iconView.backgroundColor = [UIColor whiteColor];
@@ -89,16 +90,22 @@ static NSString *const cellIdentifier = @"moreCell";
89 90
     [_stretchableTableHeaderView stretchHeaderForTableView:self.tableView withView:header];
90 91
     [self.tableView addSubview:self.iconView];
91 92
     [self.tableView addSubview:self.nickName];
93
+    
94
+    if (@available(iOS 11.0, *)) {
95
+        self.tableView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever;
96
+    } else {
97
+        self.automaticallyAdjustsScrollViewInsets = NO;
98
+    }
92 99
 }
93 100
 
94 101
 
95 102
 #pragma mark -----
96 103
 #pragma mark - UINavigationControllerDelegate
97
-// 将要显示控制器
104
+ //将要显示控制器
98 105
 - (void)navigationController:(UINavigationController *)navigationController willShowViewController:(UIViewController *)viewController animated:(BOOL)animated {
99 106
     // 判断要显示的控制器是否是自己
100 107
     BOOL isShowHomePage = [viewController isKindOfClass:[self class]];
101
-    
108
+
102 109
     [self.navigationController setNavigationBarHidden:isShowHomePage animated:YES];
103 110
 }
104 111
 

+ 1 - 1
CAIPU/Main/More(更多)/归档/HTTP/KXHTTP.m

@@ -23,7 +23,7 @@
23 23
     NSDictionary *infoDictionary = [[NSBundle mainBundle] infoDictionary];
24 24
     NSString *app_Version = [infoDictionary objectForKey:@"CFBundleShortVersionString"];
25 25
     [mgr.requestSerializer setValue:app_Version forHTTPHeaderField:@"version"];
26
-    [mgr.requestSerializer setValue:KXCHANNEL_ID forHTTPHeaderField:@"Channel-Id"];
26
+    [mgr.requestSerializer setValue:KXCHANNEL_ID forHTTPHeaderField:@"source"];
27 27
     NSString *token = [[NSUserDefaults standardUserDefaults]objectForKey:JZTOKEN];
28 28
     if (token.length>0) {
29 29
         [mgr.requestSerializer setValue:token forHTTPHeaderField:@"token"];

+ 20 - 0
CAIPU/Main/Third(第三方)/PDEmitterView/PDEmitterView.h

@@ -0,0 +1,20 @@
1
+//
2
+//  PDEmitterView.h
3
+//  PDLiveRoom
4
+//
5
+//  Created by 彭懂 on 16/9/6.
6
+//  Copyright © 2016年 彭懂. All rights reserved.
7
+//
8
+
9
+#import <UIKit/UIKit.h>
10
+
11
+@interface PDEmitterView : UIView
12
+
13
+/**
14
+ *  发射
15
+ */
16
+//- (void)sendUpEmitter;
17
+- (void)sendUpEmitterWithImageName:(NSString *)imageName;
18
+
19
+
20
+@end

+ 124 - 0
CAIPU/Main/Third(第三方)/PDEmitterView/PDEmitterView.m

@@ -0,0 +1,124 @@
1
+//
2
+//  PDEmitterView.m
3
+//  PDLiveRoom
4
+//
5
+//  Created by 彭懂 on 16/9/6.
6
+//  Copyright © 2016年 彭懂. All rights reserved.
7
+//
8
+
9
+#import "PDEmitterView.h"
10
+
11
+@interface PDEmitterView ()<CAAnimationDelegate>
12
+
13
+@property (nonatomic, strong) NSMutableArray *keepArray;
14
+@property (nonatomic, strong) NSMutableArray *deletArray;
15
+@property (nonatomic, assign) NSInteger zanCount;
16
+
17
+@end
18
+
19
+@implementation PDEmitterView
20
+
21
+// 采用tableview的回收机制
22
+- (NSMutableArray *)keepArray
23
+{
24
+    if (!_keepArray) {
25
+        _keepArray = [[NSMutableArray alloc] init];
26
+    }
27
+    return _keepArray;
28
+}
29
+
30
+- (NSMutableArray *)deletArray
31
+{
32
+    if (!_deletArray) {
33
+        _deletArray = [[NSMutableArray alloc] init];
34
+    }
35
+    return _deletArray;
36
+}
37
+
38
+- (instancetype)initWithFrame:(CGRect)frame
39
+{
40
+    self = [super initWithFrame:frame];
41
+    if (self) {
42
+        self.zanCount = 0;
43
+    }
44
+    return self;
45
+}
46
+
47
+- (void)sendUpEmitterWithImageName:(NSString *)imageName
48
+{
49
+    _zanCount ++;
50
+    if (_zanCount == INT_MAX) {
51
+        _zanCount = 0;
52
+    }
53
+    CALayer *shipLabyer = nil;
54
+//    if (self.deletArray.count > 0) {
55
+//        shipLabyer = [self.deletArray firstObject];
56
+//        [self.deletArray removeObject:shipLabyer];
57
+//    } else {
58
+//        shipLabyer = [CALayer layer];
59
+//        shipLabyer.contents = (__bridge id _Nullable)([UIImage imageNamed:imageName].CGImage);
60
+//        shipLabyer.contentsScale = [UIScreen mainScreen].scale;
61
+//        shipLabyer.frame = CGRectMake(self.bounds.size.width / 2.0, self.bounds.size.height, 40, 40);
62
+//        shipLabyer.transform = CATransform3DMakeRotation(M_PI_2, 0, 0, 1);
63
+//    }
64
+    shipLabyer = [CALayer layer];
65
+    shipLabyer.contents = (__bridge id _Nullable)([UIImage imageNamed:imageName].CGImage);
66
+    shipLabyer.contentsScale = [UIScreen mainScreen].scale;
67
+    shipLabyer.frame = CGRectMake(self.bounds.size.width / 2.0, self.bounds.size.height, 40, 40);
68
+    shipLabyer.transform = CATransform3DMakeRotation(M_PI_2, 0, 0, 1);
69
+    shipLabyer.opacity = 1.0;
70
+    [self.layer addSublayer:shipLabyer];
71
+    [self.keepArray addObject:shipLabyer];
72
+    
73
+    [self animationKeyFrameWithLayer:shipLabyer];
74
+}
75
+
76
+- (void)animationKeyFrameWithLayer:(CALayer *)layer
77
+{
78
+    NSInteger with = 60;
79
+    NSInteger height = -300;
80
+    UIBezierPath *path = [UIBezierPath bezierPath];
81
+    [path moveToPoint:CGPointMake(self.bounds.size.width / 2.0, self.bounds.size.height)];
82
+    [path addCurveToPoint:CGPointMake(arc4random() % with, 0) controlPoint1:CGPointMake((arc4random() % with) / 2.0, (arc4random() % height) / 2.0) controlPoint2:CGPointMake((with / 2.0) + (arc4random() % with) / 2.0, height / 2.0 + (arc4random() % height) / 2.0)];
83
+    
84
+    CAKeyframeAnimation *animation = [CAKeyframeAnimation animationWithKeyPath:@"position"];
85
+    animation.duration = 1.2 + (arc4random() % 9) / 10.0;
86
+    animation.duration = 2;
87
+    animation.rotationMode = kCAAnimationRotateAuto;
88
+    animation.timingFunction=[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseIn];
89
+    animation.path = path.CGPath;
90
+    animation.fillMode = kCAFillModeForwards;
91
+    
92
+    // 缩放
93
+    CABasicAnimation *scaleAnimation = [CABasicAnimation animationWithKeyPath:@"transform.scale"];
94
+    scaleAnimation.fromValue = [NSNumber numberWithFloat:1.1];
95
+    scaleAnimation.toValue = [NSNumber numberWithFloat:0.7];
96
+    scaleAnimation.duration = 1 + (arc4random() % 10) / 10.0;
97
+    
98
+    CABasicAnimation *alphaAnimation = [CABasicAnimation animationWithKeyPath:@"opacity"];
99
+    alphaAnimation.fromValue = @(1.0);
100
+    alphaAnimation.toValue = @(0);
101
+    alphaAnimation.duration = animation.duration;
102
+    alphaAnimation.fillMode = kCAFillModeForwards;
103
+    
104
+    CAAnimationGroup *animationGroup = [CAAnimationGroup animation];
105
+    animationGroup.repeatCount = 1;
106
+    animationGroup.removedOnCompletion = NO;
107
+    animationGroup.duration = animation.duration;
108
+    animationGroup.fillMode = kCAFillModeForwards;
109
+    animationGroup.animations = @[animation, scaleAnimation, alphaAnimation];
110
+    animationGroup.delegate = self;
111
+    [layer addAnimation:animationGroup forKey:[NSString stringWithFormat:@"animation%zd", _zanCount]];
112
+
113
+}
114
+
115
+- (void)animationDidStop:(CAAnimation *)anim finished:(BOOL)flag
116
+{
117
+    CALayer *layer = [self.keepArray firstObject];
118
+    [layer removeAllAnimations];
119
+//    [self.deletArray addObject:layer];
120
+    [layer removeFromSuperlayer];
121
+    [self.keepArray removeObject:layer];
122
+}
123
+
124
+@end

+ 19 - 0
CAIPU/Main/Third(第三方)/SPScrollNumLabel/SPScrollNumLabel.h

@@ -0,0 +1,19 @@
1
+//
2
+//  SPScrollNumLabel.h
3
+//  SPScrollNumLabel
4
+//
5
+//  Created by Tree on 2017/11/21.
6
+//  Copyright © 2017年 Tr2e. All rights reserved.
7
+//
8
+
9
+#import <UIKit/UIKit.h>
10
+
11
+IB_DESIGNABLE
12
+@interface SPScrollNumLabel : UILabel
13
+@property (nonatomic, assign) IBInspectable NSInteger targetNumber;// default is 0
14
+@property (nonatomic, assign) IBInspectable CGFloat animateDuration;// default is 0.25
15
+@property (nonatomic, assign) IBInspectable BOOL isCommonLabel;// default is NO
16
+@property (nonatomic, assign) BOOL centerPointPriority;// default is NO
17
+- (void)increaseNumber:(NSInteger)increasedNum;
18
+- (void)decreaseNumber:(NSInteger)decreasedNum;
19
+@end

+ 211 - 0
CAIPU/Main/Third(第三方)/SPScrollNumLabel/SPScrollNumLabel.m

@@ -0,0 +1,211 @@
1
+//
2
+//  SPScrollNumLabel.m
3
+//  SPScrollNumLabel
4
+//
5
+//  Created by Tree on 2017/11/21.
6
+//  Copyright © 2017年 Tr2e. All rights reserved.
7
+//
8
+
9
+#import "SPScrollNumLabel.h"
10
+
11
+@interface SPScrollNumLabel (){
12
+    BOOL has_centerPoint_detect;
13
+    BOOL is_initializeFromXib;
14
+}
15
+@property (nonatomic, strong) UIColor *sp_textColor;// default is black
16
+@property (nonatomic, copy) NSArray <NSString *> *sepNumArr;
17
+@property (nonatomic, copy) NSArray <UILabel *> *sepLabelArr;
18
+
19
+@end
20
+
21
+@implementation SPScrollNumLabel
22
+
23
+// initialize
24
+- (instancetype)initWithCoder:(NSCoder *)aDecoder{
25
+    if (self = [super initWithCoder:aDecoder]) {
26
+        [self initailizeConfig];
27
+    }
28
+    return self;
29
+}
30
+
31
+- (void)layoutSubviews{
32
+    [super layoutSubviews];
33
+}
34
+
35
+- (void)willMoveToWindow:(UIWindow *)newWindow{
36
+    [super willMoveToWindow:newWindow];
37
+    if (!_targetNumber && !self.isCommonLabel) {
38
+        self.targetNumber = 0;
39
+    }
40
+}
41
+
42
+- (void)initailizeConfig{
43
+    is_initializeFromXib = YES;
44
+    if (!self.isCommonLabel) {
45
+        self.sp_textColor = self.textColor;
46
+        self.textColor = [UIColor clearColor];
47
+    }
48
+}
49
+
50
+// function
51
+- (void)increaseNumber:(NSInteger)increasedNum{
52
+    self.targetNumber += increasedNum;
53
+}
54
+
55
+- (void)decreaseNumber:(NSInteger)decreasedNum{
56
+    self.targetNumber -= decreasedNum;
57
+}
58
+
59
+- (void)operateWithTargetString:(NSString *)string{
60
+    __weak typeof(self) ws = self;
61
+    [self seprateStringToSingleWithTarget:string operateHandler:^(NSMutableArray<NSString *> *sepStrArr, NSMutableArray<UILabel *> *sepLabelArr) {
62
+        [ws showScrollAnimiationWithSepStrArr:sepStrArr sepLableArr:sepLabelArr];
63
+    }];
64
+}
65
+
66
+- (void)showScrollAnimiationWithSepStrArr:(NSArray <NSString *>*)sepStrArr sepLableArr:(NSArray <UILabel *> *)sepLabelArr{
67
+    NSInteger targetLength = sepLabelArr.count;
68
+    NSInteger hisLength = self.sepLabelArr.count;
69
+    for (NSInteger i = 0; i < targetLength; i ++) {
70
+        NSInteger targetIndex = targetLength - i - 1;
71
+        NSInteger hisTargetIndex = hisLength - i - 1;
72
+        if (i < hisLength) {
73
+            if (![sepStrArr[targetIndex] isEqualToString:self.sepNumArr[hisTargetIndex]]) {
74
+                BOOL increase = sepStrArr[targetIndex].integerValue > self.sepNumArr[hisTargetIndex].integerValue;
75
+                // his label
76
+                UILabel *hisLabel = self.sepLabelArr[hisTargetIndex];
77
+                CGRect hisTargetFrame = CGRectOffset(hisLabel.frame, 0, (increase?-1:1)*hisLabel.frame.size.height);
78
+                // new label
79
+                UILabel *label = sepLabelArr[targetIndex];
80
+                CGRect frame = label.frame;
81
+                CGRect targetFrame = CGRectOffset(frame, 0, (increase?1:-1)*label.frame.size.height);
82
+                label.frame = targetFrame;
83
+                label.alpha = 0;
84
+                [UIView animateWithDuration:self.animateDuration?self.animateDuration:0.25 delay:0 options:UIViewAnimationOptionCurveEaseOut animations:^{
85
+                    hisLabel.frame = hisTargetFrame;
86
+                    label.frame = frame;
87
+                    hisLabel.alpha = 0;
88
+                    label.alpha = 1;
89
+                } completion:^(BOOL finished) {
90
+                    [hisLabel removeFromSuperview];
91
+                }];
92
+            }else{
93
+                [self.sepLabelArr[hisTargetIndex] removeFromSuperview];
94
+            }
95
+        }else{
96
+            UILabel *label = sepLabelArr[targetIndex];
97
+            CGRect frame = label.frame;
98
+            label.alpha = 0;
99
+            label.frame = CGRectOffset(frame, 0, -frame.size.height);
100
+            [UIView animateWithDuration:self.animateDuration?self.animateDuration:0.25 delay:0 usingSpringWithDamping:0.8 initialSpringVelocity:2 options:UIViewAnimationOptionCurveEaseOut animations:^{
101
+                label.frame = frame;
102
+                label.alpha = 1;
103
+            } completion:nil];
104
+        }
105
+    }
106
+    
107
+    if (hisLength > targetLength) {
108
+        for (int i = 0; i < hisLength - targetLength; i ++) {
109
+            UILabel *label = self.sepLabelArr[i];
110
+            CGRect hisTargetFrame = CGRectOffset(label.frame, 0, -1*label.frame.size.height);
111
+            [UIView animateWithDuration:self.animateDuration?self.animateDuration:0.25 delay:0 options:UIViewAnimationOptionCurveEaseOut animations:^{
112
+                label.frame = hisTargetFrame;
113
+                label.alpha = 0;
114
+            } completion:^(BOOL finished) {
115
+                [label removeFromSuperview];
116
+            }];
117
+        }
118
+    }
119
+    self.sepNumArr = sepStrArr;
120
+    self.sepLabelArr = sepLabelArr;
121
+}
122
+
123
+// private operation
124
+- (UILabel *)createLabelWithString:(NSString *)numberStr{
125
+    UILabel *label = [[UILabel alloc] init];
126
+    label.font = self.font;
127
+    label.textColor = self.sp_textColor?self.sp_textColor:self.textColor;
128
+    label.textAlignment = NSTextAlignmentLeft;
129
+    label.text = numberStr;
130
+    [label sizeToFit];
131
+    return label;
132
+}
133
+
134
+- (void)seprateStringToSingleWithTarget:(NSString *)target operateHandler:(void (^) (NSMutableArray<NSString *> *sepStrArr,NSMutableArray<UILabel *> *sepLabelArr)) handler{
135
+    NSMutableArray <NSString *> * sepStrArr = [[NSMutableArray alloc] initWithCapacity:target.length];
136
+    NSMutableArray <UILabel *> * sepLabelArr = [[NSMutableArray alloc] initWithCapacity:sepStrArr.count];
137
+    for (NSInteger i = 0 ; i < target.length; i ++) {
138
+        // str
139
+        NSString *subStr = [target substringWithRange:NSMakeRange(i, 1)];
140
+        [sepStrArr addObject:subStr];
141
+        // label
142
+        UILabel *label = [self createLabelWithString:subStr];
143
+        CGFloat labelHeight = label.frame.size.height;
144
+        CGFloat selfHeight = self.frame.size.height;
145
+        label.frame = (CGRect){CGPointMake(sepLabelArr.count?CGRectGetMaxX(sepLabelArr.lastObject.frame):0, (labelHeight < selfHeight ? (selfHeight - labelHeight)/2: 0)),label.frame.size};
146
+        [sepLabelArr addObject:label];
147
+        [self addSubview:label];
148
+    }
149
+    
150
+    CGFloat labelHeight = sepLabelArr.lastObject.frame.size.height;
151
+    CGFloat selfHeight = self.frame.size.height;
152
+    CGRect changedFrame = (CGRect){self.frame.origin,CGSizeMake(CGRectGetMaxX(sepLabelArr.lastObject.frame), selfHeight<labelHeight?labelHeight:selfHeight)};
153
+    
154
+    // center point detect
155
+    if (self.centerPointPriority && changedFrame.size.width != self.frame.size.width && has_centerPoint_detect) {
156
+        changedFrame = CGRectOffset(changedFrame, (self.frame.size.width - changedFrame.size.width)/2, 0);
157
+    }
158
+    if (self.centerPointPriority && !has_centerPoint_detect) {
159
+        changedFrame = CGRectOffset(changedFrame, - changedFrame.size.width/2, - changedFrame.size.height/2);
160
+        has_centerPoint_detect = YES;
161
+    }
162
+    
163
+    self.frame = changedFrame;
164
+    handler([sepStrArr copy],[sepLabelArr copy]);
165
+}
166
+
167
+// set
168
+- (void)setTextColor:(UIColor *)textColor{
169
+    if (!is_initializeFromXib) {
170
+        self.sp_textColor = textColor;
171
+    }
172
+    if (!self.isCommonLabel) {
173
+        [super setTextColor:[UIColor clearColor]];
174
+    }else{
175
+        [super setTextColor:textColor];
176
+    }
177
+}
178
+
179
+- (void)setIsCommonLabel:(BOOL)isCommonLabel{
180
+    _isCommonLabel = isCommonLabel;
181
+    [super setTextColor:isCommonLabel?self.sp_textColor:[UIColor clearColor]];
182
+}
183
+
184
+- (void)setText:(NSString *)text{
185
+    [super setText:text];
186
+    if (self.textColor == [UIColor clearColor] && self.isCommonLabel) {
187
+        self.textColor = self.sp_textColor;
188
+    }
189
+    if ([self validateValueIsTotalNumber:text]) {
190
+        _targetNumber = text.integerValue;
191
+    }
192
+    if (!self.isCommonLabel) {
193
+        [self operateWithTargetString:text];
194
+    }
195
+}
196
+
197
+- (void)setTargetNumber:(NSInteger)targetNumber{
198
+    if (self.isCommonLabel) {
199
+        return;
200
+    }
201
+    _targetNumber = targetNumber;
202
+    [self setText:[NSString stringWithFormat:@"%ld",targetNumber]];
203
+}
204
+
205
+- (BOOL)validateValueIsTotalNumber:(NSString *)text{
206
+    NSString *reg = @"^-?\\d*$";
207
+    NSPredicate *predicate = [NSPredicate predicateWithFormat:@"SELF MATCHES %@", reg];
208
+    return [predicate evaluateWithObject:text];
209
+}
210
+
211
+@end

+ 1 - 0
CAIPU/Main/Tools(工具)/CPHTTP.m

@@ -20,6 +20,7 @@
20 20
     NSDictionary *infoDictionary = [[NSBundle mainBundle] infoDictionary];
21 21
     NSString *app_Version = [infoDictionary objectForKey:@"CFBundleShortVersionString"];
22 22
     [mgr.requestSerializer setValue:app_Version forHTTPHeaderField:@"version"];
23
+    [mgr.requestSerializer setValue:KXCHANNEL_ID forHTTPHeaderField:@"source"];
23 24
 //    NSDate *date = [NSDate date];
24 25
 //    NSInteger time = [date timeIntervalSince1970];
25 26
 //    NSString *timeStr = [NSString stringWithFormat:@"%ld",(long)time];