Commit 319a2c13eef5cbda21cd5aa73f6e3f2f922fbf9a
1 parent
5a02b24c
完善聊天室和弹幕交互的逻辑
Showing
41 changed files
with
1591 additions
and
605 deletions
LiveVideoCloud/LiveVideoCloud.xcodeproj/project.pbxproj
| ... | ... | @@ -122,18 +122,23 @@ |
| 122 | 122 | D2029D091E6EAE2E0027CD92 /* Foundation+Log.m in Sources */ = {isa = PBXBuildFile; fileRef = D2029CF21E6EAE2E0027CD92 /* Foundation+Log.m */; }; |
| 123 | 123 | D2029D0A1E6EAE2E0027CD92 /* ZXServerUrl.m in Sources */ = {isa = PBXBuildFile; fileRef = D2029CFE1E6EAE2E0027CD92 /* ZXServerUrl.m */; }; |
| 124 | 124 | D2029D161E6EB00D0027CD92 /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = D2029D151E6EB00D0027CD92 /* AppDelegate.m */; }; |
| 125 | + D207BE9E1E84BD68006A0CE8 /* BarrageManager.m in Sources */ = {isa = PBXBuildFile; fileRef = D207BE9D1E84BD68006A0CE8 /* BarrageManager.m */; }; | |
| 126 | + D207BEA11E84C1EC006A0CE8 /* AnimationBaseView.m in Sources */ = {isa = PBXBuildFile; fileRef = D207BEA01E84C1EC006A0CE8 /* AnimationBaseView.m */; }; | |
| 125 | 127 | D217A24A1E7B76C7003B44CB /* PresentView.m in Sources */ = {isa = PBXBuildFile; fileRef = D217A2471E7B76C7003B44CB /* PresentView.m */; }; |
| 126 | 128 | D217A24B1E7B76C7003B44CB /* PresentViewCell.m in Sources */ = {isa = PBXBuildFile; fileRef = D217A2491E7B76C7003B44CB /* PresentViewCell.m */; }; |
| 127 | 129 | D217A24E1E7B77C7003B44CB /* ComboCell.m in Sources */ = {isa = PBXBuildFile; fileRef = D217A24D1E7B77C7003B44CB /* ComboCell.m */; }; |
| 130 | + D224B1971E826ED800CC61D0 /* ChatBarrageAnimAction.m in Sources */ = {isa = PBXBuildFile; fileRef = D224B1961E826ED800CC61D0 /* ChatBarrageAnimAction.m */; }; | |
| 128 | 131 | D22830F11E778C0F00627701 /* LiveBaseView.m in Sources */ = {isa = PBXBuildFile; fileRef = D22830F01E778C0F00627701 /* LiveBaseView.m */; }; |
| 129 | 132 | D22830FC1E77C2D900627701 /* BottomToolView.m in Sources */ = {isa = PBXBuildFile; fileRef = D22830FB1E77C2D900627701 /* BottomToolView.m */; }; |
| 130 | 133 | D22830FF1E77C69E00627701 /* GiftListView.m in Sources */ = {isa = PBXBuildFile; fileRef = D22830FE1E77C69E00627701 /* GiftListView.m */; }; |
| 131 | 134 | D22831091E77D8D500627701 /* GiftModel.m in Sources */ = {isa = PBXBuildFile; fileRef = D22831081E77D8D500627701 /* GiftModel.m */; }; |
| 132 | 135 | D236967E1E7F9E4100E4BF71 /* GiftPayButton.m in Sources */ = {isa = PBXBuildFile; fileRef = D236967D1E7F9E4100E4BF71 /* GiftPayButton.m */; }; |
| 133 | 136 | D23696841E7FC6A900E4BF71 /* chatListCell.m in Sources */ = {isa = PBXBuildFile; fileRef = D23696831E7FC6A900E4BF71 /* chatListCell.m */; }; |
| 134 | - D236968D1E7FC7C200E4BF71 /* CNBarrageManager.m in Sources */ = {isa = PBXBuildFile; fileRef = D236968A1E7FC7C200E4BF71 /* CNBarrageManager.m */; }; | |
| 135 | - D236968E1E7FC7C200E4BF71 /* CNBarrageView.m in Sources */ = {isa = PBXBuildFile; fileRef = D236968C1E7FC7C200E4BF71 /* CNBarrageView.m */; }; | |
| 136 | 137 | D23696921E7FC83800E4BF71 /* chatMsgModel.m in Sources */ = {isa = PBXBuildFile; fileRef = D23696911E7FC83800E4BF71 /* chatMsgModel.m */; }; |
| 138 | + D24571581E8393EB00AA85D6 /* UIImageView+ZXExtension.m in Sources */ = {isa = PBXBuildFile; fileRef = D24571571E8393EB00AA85D6 /* UIImageView+ZXExtension.m */; }; | |
| 139 | + D245715C1E83A62B00AA85D6 /* BounceView.m in Sources */ = {isa = PBXBuildFile; fileRef = D245715B1E83A62B00AA85D6 /* BounceView.m */; }; | |
| 140 | + D245715F1E83B09900AA85D6 /* userInfoModel.m in Sources */ = {isa = PBXBuildFile; fileRef = D245715E1E83B09900AA85D6 /* userInfoModel.m */; }; | |
| 141 | + D24571631E83C40B00AA85D6 /* PrivateView.m in Sources */ = {isa = PBXBuildFile; fileRef = D24571621E83C40B00AA85D6 /* PrivateView.m */; }; | |
| 137 | 142 | D25530001E7909AC00DF38A5 /* GiftAnimOperation.m in Sources */ = {isa = PBXBuildFile; fileRef = D2552FFF1E7909AC00DF38A5 /* GiftAnimOperation.m */; }; |
| 138 | 143 | D25530031E79115100DF38A5 /* AnimQueueManager.m in Sources */ = {isa = PBXBuildFile; fileRef = D25530021E79115100DF38A5 /* AnimQueueManager.m */; }; |
| 139 | 144 | D25530061E7911A800DF38A5 /* GiftAnimationAction.m in Sources */ = {isa = PBXBuildFile; fileRef = D25530051E7911A800DF38A5 /* GiftAnimationAction.m */; }; |
| ... | ... | @@ -170,6 +175,9 @@ |
| 170 | 175 | D2888DB41E6EC154003A77C8 /* HomeViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = D2888DB31E6EC154003A77C8 /* HomeViewController.m */; }; |
| 171 | 176 | D2888DB71E6EC1B8003A77C8 /* LVCMyViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = D2888DB61E6EC1B8003A77C8 /* LVCMyViewController.m */; }; |
| 172 | 177 | D2A803081E80BD6F009D6F1C /* TopToolView.m in Sources */ = {isa = PBXBuildFile; fileRef = D2A803071E80BD6F009D6F1C /* TopToolView.m */; }; |
| 178 | + D2B7B2511E8247D400ED084E /* ChatBarrageManager.m in Sources */ = {isa = PBXBuildFile; fileRef = D2B7B2501E8247D400ED084E /* ChatBarrageManager.m */; }; | |
| 179 | + D2B7B2541E824B2D00ED084E /* ChatBarrageView.m in Sources */ = {isa = PBXBuildFile; fileRef = D2B7B2531E824B2D00ED084E /* ChatBarrageView.m */; }; | |
| 180 | + D2B7B2571E8261EF00ED084E /* ChatBarrOperation.m in Sources */ = {isa = PBXBuildFile; fileRef = D2B7B2561E8261EF00ED084E /* ChatBarrOperation.m */; }; | |
| 173 | 181 | /* End PBXBuildFile section */ |
| 174 | 182 | |
| 175 | 183 | /* Begin PBXContainerItemProxy section */ |
| ... | ... | @@ -453,6 +461,10 @@ |
| 453 | 461 | D2029CFF1E6EAE2E0027CD92 /* UtilKits.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = UtilKits.h; sourceTree = "<group>"; }; |
| 454 | 462 | D2029D121E6EAF8D0027CD92 /* AppDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = "<group>"; }; |
| 455 | 463 | D2029D151E6EB00D0027CD92 /* AppDelegate.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = "<group>"; }; |
| 464 | + D207BE9C1E84BD68006A0CE8 /* BarrageManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BarrageManager.h; sourceTree = "<group>"; }; | |
| 465 | + D207BE9D1E84BD68006A0CE8 /* BarrageManager.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = BarrageManager.m; sourceTree = "<group>"; }; | |
| 466 | + D207BE9F1E84C1EC006A0CE8 /* AnimationBaseView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AnimationBaseView.h; sourceTree = "<group>"; }; | |
| 467 | + D207BEA01E84C1EC006A0CE8 /* AnimationBaseView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AnimationBaseView.m; sourceTree = "<group>"; }; | |
| 456 | 468 | D217A2451E7B76C7003B44CB /* PresentModelAble.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PresentModelAble.h; sourceTree = "<group>"; }; |
| 457 | 469 | D217A2461E7B76C7003B44CB /* PresentView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PresentView.h; sourceTree = "<group>"; }; |
| 458 | 470 | D217A2471E7B76C7003B44CB /* PresentView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = PresentView.m; sourceTree = "<group>"; }; |
| ... | ... | @@ -460,6 +472,8 @@ |
| 460 | 472 | D217A2491E7B76C7003B44CB /* PresentViewCell.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = PresentViewCell.m; sourceTree = "<group>"; }; |
| 461 | 473 | D217A24C1E7B77C7003B44CB /* ComboCell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ComboCell.h; path = Present/ComboCell.h; sourceTree = "<group>"; }; |
| 462 | 474 | D217A24D1E7B77C7003B44CB /* ComboCell.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = ComboCell.m; path = Present/ComboCell.m; sourceTree = "<group>"; }; |
| 475 | + D224B1951E826ED800CC61D0 /* ChatBarrageAnimAction.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ChatBarrageAnimAction.h; sourceTree = "<group>"; }; | |
| 476 | + D224B1961E826ED800CC61D0 /* ChatBarrageAnimAction.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ChatBarrageAnimAction.m; sourceTree = "<group>"; }; | |
| 463 | 477 | D22830EF1E778C0F00627701 /* LiveBaseView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LiveBaseView.h; sourceTree = "<group>"; }; |
| 464 | 478 | D22830F01E778C0F00627701 /* LiveBaseView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = LiveBaseView.m; sourceTree = "<group>"; }; |
| 465 | 479 | D22830FA1E77C2D900627701 /* BottomToolView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BottomToolView.h; sourceTree = "<group>"; }; |
| ... | ... | @@ -472,12 +486,16 @@ |
| 472 | 486 | D236967D1E7F9E4100E4BF71 /* GiftPayButton.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GiftPayButton.m; sourceTree = "<group>"; }; |
| 473 | 487 | D23696821E7FC6A900E4BF71 /* chatListCell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = chatListCell.h; sourceTree = "<group>"; }; |
| 474 | 488 | D23696831E7FC6A900E4BF71 /* chatListCell.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = chatListCell.m; sourceTree = "<group>"; }; |
| 475 | - D23696891E7FC7C200E4BF71 /* CNBarrageManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CNBarrageManager.h; sourceTree = "<group>"; }; | |
| 476 | - D236968A1E7FC7C200E4BF71 /* CNBarrageManager.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CNBarrageManager.m; sourceTree = "<group>"; }; | |
| 477 | - D236968B1E7FC7C200E4BF71 /* CNBarrageView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CNBarrageView.h; sourceTree = "<group>"; }; | |
| 478 | - D236968C1E7FC7C200E4BF71 /* CNBarrageView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CNBarrageView.m; sourceTree = "<group>"; }; | |
| 479 | 489 | D23696901E7FC83800E4BF71 /* chatMsgModel.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = chatMsgModel.h; sourceTree = "<group>"; }; |
| 480 | 490 | D23696911E7FC83800E4BF71 /* chatMsgModel.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = chatMsgModel.m; sourceTree = "<group>"; }; |
| 491 | + D24571561E8393EB00AA85D6 /* UIImageView+ZXExtension.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "UIImageView+ZXExtension.h"; sourceTree = "<group>"; }; | |
| 492 | + D24571571E8393EB00AA85D6 /* UIImageView+ZXExtension.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "UIImageView+ZXExtension.m"; sourceTree = "<group>"; }; | |
| 493 | + D245715A1E83A62B00AA85D6 /* BounceView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BounceView.h; sourceTree = "<group>"; }; | |
| 494 | + D245715B1E83A62B00AA85D6 /* BounceView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = BounceView.m; sourceTree = "<group>"; }; | |
| 495 | + D245715D1E83B09900AA85D6 /* userInfoModel.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = userInfoModel.h; sourceTree = "<group>"; }; | |
| 496 | + D245715E1E83B09900AA85D6 /* userInfoModel.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = userInfoModel.m; sourceTree = "<group>"; }; | |
| 497 | + D24571611E83C40B00AA85D6 /* PrivateView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PrivateView.h; sourceTree = "<group>"; }; | |
| 498 | + D24571621E83C40B00AA85D6 /* PrivateView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = PrivateView.m; sourceTree = "<group>"; }; | |
| 481 | 499 | D2552FFE1E7909AC00DF38A5 /* GiftAnimOperation.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GiftAnimOperation.h; sourceTree = "<group>"; }; |
| 482 | 500 | D2552FFF1E7909AC00DF38A5 /* GiftAnimOperation.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GiftAnimOperation.m; sourceTree = "<group>"; }; |
| 483 | 501 | D25530011E79115100DF38A5 /* AnimQueueManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AnimQueueManager.h; sourceTree = "<group>"; }; |
| ... | ... | @@ -535,6 +553,12 @@ |
| 535 | 553 | D2888DB61E6EC1B8003A77C8 /* LVCMyViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = LVCMyViewController.m; sourceTree = "<group>"; }; |
| 536 | 554 | D2A803061E80BD6F009D6F1C /* TopToolView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TopToolView.h; sourceTree = "<group>"; }; |
| 537 | 555 | D2A803071E80BD6F009D6F1C /* TopToolView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = TopToolView.m; sourceTree = "<group>"; }; |
| 556 | + D2B7B24F1E8247D400ED084E /* ChatBarrageManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ChatBarrageManager.h; sourceTree = "<group>"; }; | |
| 557 | + D2B7B2501E8247D400ED084E /* ChatBarrageManager.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ChatBarrageManager.m; sourceTree = "<group>"; }; | |
| 558 | + D2B7B2521E824B2D00ED084E /* ChatBarrageView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ChatBarrageView.h; sourceTree = "<group>"; }; | |
| 559 | + D2B7B2531E824B2D00ED084E /* ChatBarrageView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ChatBarrageView.m; sourceTree = "<group>"; }; | |
| 560 | + D2B7B2551E8261EF00ED084E /* ChatBarrOperation.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ChatBarrOperation.h; sourceTree = "<group>"; }; | |
| 561 | + D2B7B2561E8261EF00ED084E /* ChatBarrOperation.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ChatBarrOperation.m; sourceTree = "<group>"; }; | |
| 538 | 562 | /* End PBXFileReference section */ |
| 539 | 563 | |
| 540 | 564 | /* Begin PBXFrameworksBuildPhase section */ |
| ... | ... | @@ -601,14 +625,6 @@ |
| 601 | 625 | path = Masonry; |
| 602 | 626 | sourceTree = "<group>"; |
| 603 | 627 | }; |
| 604 | - 812E504D1E769995004F5FCD /* CNLiveSDK */ = { | |
| 605 | - isa = PBXGroup; | |
| 606 | - children = ( | |
| 607 | - ); | |
| 608 | - name = CNLiveSDK; | |
| 609 | - path = LiveVideoCloud/Classes/CNLiveSDK; | |
| 610 | - sourceTree = SOURCE_ROOT; | |
| 611 | - }; | |
| 612 | 628 | 812E504E1E7699B9004F5FCD /* CNLiveSDK */ = { |
| 613 | 629 | isa = PBXGroup; |
| 614 | 630 | children = ( |
| ... | ... | @@ -744,7 +760,6 @@ |
| 744 | 760 | D2029BD11E6EADE10027CD92 /* Helpers */ = { |
| 745 | 761 | isa = PBXGroup; |
| 746 | 762 | children = ( |
| 747 | - 812E504D1E769995004F5FCD /* CNLiveSDK */, | |
| 748 | 763 | D2029BD21E6EADE10027CD92 /* Tools.h */, |
| 749 | 764 | D2029BD31E6EADE10027CD92 /* Tools.m */, |
| 750 | 765 | ); |
| ... | ... | @@ -1129,6 +1144,8 @@ |
| 1129 | 1144 | D2029CDD1E6EAE2E0027CD92 /* Category */ = { |
| 1130 | 1145 | isa = PBXGroup; |
| 1131 | 1146 | children = ( |
| 1147 | + D24571561E8393EB00AA85D6 /* UIImageView+ZXExtension.h */, | |
| 1148 | + D24571571E8393EB00AA85D6 /* UIImageView+ZXExtension.m */, | |
| 1132 | 1149 | D2029CDE1E6EAE2E0027CD92 /* NSNumber+ScaleHeight.h */, |
| 1133 | 1150 | D2029CDF1E6EAE2E0027CD92 /* NSNumber+ScaleHeight.m */, |
| 1134 | 1151 | D2029CE01E6EAE2E0027CD92 /* UIColor+HexString.h */, |
| ... | ... | @@ -1207,6 +1224,15 @@ |
| 1207 | 1224 | path = AppDelegate; |
| 1208 | 1225 | sourceTree = "<group>"; |
| 1209 | 1226 | }; |
| 1227 | + D207BE9B1E84BD3E006A0CE8 /* BarrageManager */ = { | |
| 1228 | + isa = PBXGroup; | |
| 1229 | + children = ( | |
| 1230 | + D207BE9C1E84BD68006A0CE8 /* BarrageManager.h */, | |
| 1231 | + D207BE9D1E84BD68006A0CE8 /* BarrageManager.m */, | |
| 1232 | + ); | |
| 1233 | + path = BarrageManager; | |
| 1234 | + sourceTree = "<group>"; | |
| 1235 | + }; | |
| 1210 | 1236 | D217A2441E7B76C7003B44CB /* Present */ = { |
| 1211 | 1237 | isa = PBXGroup; |
| 1212 | 1238 | children = ( |
| ... | ... | @@ -1233,7 +1259,8 @@ |
| 1233 | 1259 | D22830F61E77C26C00627701 /* Chat */ = { |
| 1234 | 1260 | isa = PBXGroup; |
| 1235 | 1261 | children = ( |
| 1236 | - D23696881E7FC7C200E4BF71 /* Barrage */, | |
| 1262 | + D207BE9B1E84BD3E006A0CE8 /* BarrageManager */, | |
| 1263 | + D2B7B24E1E8247B500ED084E /* ChatBarrageManager */, | |
| 1237 | 1264 | D236968F1E7FC83800E4BF71 /* ChatMsgModel */, |
| 1238 | 1265 | D22830F71E77C27A00627701 /* ChatViews */, |
| 1239 | 1266 | ); |
| ... | ... | @@ -1276,32 +1303,45 @@ |
| 1276 | 1303 | path = GiftModel; |
| 1277 | 1304 | sourceTree = "<group>"; |
| 1278 | 1305 | }; |
| 1279 | - D23696881E7FC7C200E4BF71 /* Barrage */ = { | |
| 1306 | + D236968F1E7FC83800E4BF71 /* ChatMsgModel */ = { | |
| 1280 | 1307 | isa = PBXGroup; |
| 1281 | 1308 | children = ( |
| 1282 | - D23696891E7FC7C200E4BF71 /* CNBarrageManager.h */, | |
| 1283 | - D236968A1E7FC7C200E4BF71 /* CNBarrageManager.m */, | |
| 1284 | - D236968B1E7FC7C200E4BF71 /* CNBarrageView.h */, | |
| 1285 | - D236968C1E7FC7C200E4BF71 /* CNBarrageView.m */, | |
| 1309 | + D23696901E7FC83800E4BF71 /* chatMsgModel.h */, | |
| 1310 | + D23696911E7FC83800E4BF71 /* chatMsgModel.m */, | |
| 1286 | 1311 | ); |
| 1287 | - path = Barrage; | |
| 1312 | + path = ChatMsgModel; | |
| 1288 | 1313 | sourceTree = "<group>"; |
| 1289 | 1314 | }; |
| 1290 | - D236968F1E7FC83800E4BF71 /* ChatMsgModel */ = { | |
| 1315 | + D24571591E83A61E00AA85D6 /* BounceView */ = { | |
| 1291 | 1316 | isa = PBXGroup; |
| 1292 | 1317 | children = ( |
| 1293 | - D23696901E7FC83800E4BF71 /* chatMsgModel.h */, | |
| 1294 | - D23696911E7FC83800E4BF71 /* chatMsgModel.m */, | |
| 1318 | + D245715A1E83A62B00AA85D6 /* BounceView.h */, | |
| 1319 | + D245715B1E83A62B00AA85D6 /* BounceView.m */, | |
| 1295 | 1320 | ); |
| 1296 | - path = ChatMsgModel; | |
| 1321 | + name = BounceView; | |
| 1322 | + sourceTree = "<group>"; | |
| 1323 | + }; | |
| 1324 | + D24571601E83C3F900AA85D6 /* PrivateView */ = { | |
| 1325 | + isa = PBXGroup; | |
| 1326 | + children = ( | |
| 1327 | + D24571611E83C40B00AA85D6 /* PrivateView.h */, | |
| 1328 | + D24571621E83C40B00AA85D6 /* PrivateView.m */, | |
| 1329 | + ); | |
| 1330 | + path = PrivateView; | |
| 1297 | 1331 | sourceTree = "<group>"; |
| 1298 | 1332 | }; |
| 1299 | 1333 | D2575C431E76846900E3A8FC /* InteractionSections */ = { |
| 1300 | 1334 | isa = PBXGroup; |
| 1301 | 1335 | children = ( |
| 1336 | + D24571601E83C3F900AA85D6 /* PrivateView */, | |
| 1337 | + D24571591E83A61E00AA85D6 /* BounceView */, | |
| 1302 | 1338 | D22830F91E77C2D900627701 /* BottomToolView */, |
| 1303 | 1339 | D22830F81E77C2A700627701 /* TopToolView */, |
| 1304 | 1340 | D22830F61E77C26C00627701 /* Chat */, |
| 1341 | + D245715D1E83B09900AA85D6 /* userInfoModel.h */, | |
| 1342 | + D245715E1E83B09900AA85D6 /* userInfoModel.m */, | |
| 1343 | + D207BE9F1E84C1EC006A0CE8 /* AnimationBaseView.h */, | |
| 1344 | + D207BEA01E84C1EC006A0CE8 /* AnimationBaseView.m */, | |
| 1305 | 1345 | D22830EF1E778C0F00627701 /* LiveBaseView.h */, |
| 1306 | 1346 | D22830F01E778C0F00627701 /* LiveBaseView.m */, |
| 1307 | 1347 | D2575C651E76A25400E3A8FC /* LVCInteractionController.h */, |
| ... | ... | @@ -1539,6 +1579,21 @@ |
| 1539 | 1579 | path = View; |
| 1540 | 1580 | sourceTree = "<group>"; |
| 1541 | 1581 | }; |
| 1582 | + D2B7B24E1E8247B500ED084E /* ChatBarrageManager */ = { | |
| 1583 | + isa = PBXGroup; | |
| 1584 | + children = ( | |
| 1585 | + D2B7B2551E8261EF00ED084E /* ChatBarrOperation.h */, | |
| 1586 | + D2B7B2561E8261EF00ED084E /* ChatBarrOperation.m */, | |
| 1587 | + D2B7B24F1E8247D400ED084E /* ChatBarrageManager.h */, | |
| 1588 | + D2B7B2501E8247D400ED084E /* ChatBarrageManager.m */, | |
| 1589 | + D2B7B2521E824B2D00ED084E /* ChatBarrageView.h */, | |
| 1590 | + D2B7B2531E824B2D00ED084E /* ChatBarrageView.m */, | |
| 1591 | + D224B1951E826ED800CC61D0 /* ChatBarrageAnimAction.h */, | |
| 1592 | + D224B1961E826ED800CC61D0 /* ChatBarrageAnimAction.m */, | |
| 1593 | + ); | |
| 1594 | + path = ChatBarrageManager; | |
| 1595 | + sourceTree = "<group>"; | |
| 1596 | + }; | |
| 1542 | 1597 | /* End PBXGroup section */ |
| 1543 | 1598 | |
| 1544 | 1599 | /* Begin PBXNativeTarget section */ |
| ... | ... | @@ -1694,6 +1749,7 @@ |
| 1694 | 1749 | D2029CBB1E6EADE10027CD92 /* SDWebImageDownloader.m in Sources */, |
| 1695 | 1750 | D2029CA71E6EADE10027CD92 /* MJRefreshAutoGifFooter.m in Sources */, |
| 1696 | 1751 | D2029CC11E6EADE10027CD92 /* UIImage+MultiFormat.m in Sources */, |
| 1752 | + D245715F1E83B09900AA85D6 /* userInfoModel.m in Sources */, | |
| 1697 | 1753 | D2029C861E6EADE10027CD92 /* Tools.m in Sources */, |
| 1698 | 1754 | D25BF8931E7FBAEA007FB138 /* LVCUGCBackgroundView.m in Sources */, |
| 1699 | 1755 | D2029CA01E6EADE10027CD92 /* NSObject+MJProperty.m in Sources */, |
| ... | ... | @@ -1722,6 +1778,7 @@ |
| 1722 | 1778 | D2888DB71E6EC1B8003A77C8 /* LVCMyViewController.m in Sources */, |
| 1723 | 1779 | D2029CBE1E6EADE10027CD92 /* SDWebImagePrefetcher.m in Sources */, |
| 1724 | 1780 | D2A803081E80BD6F009D6F1C /* TopToolView.m in Sources */, |
| 1781 | + D2B7B2571E8261EF00ED084E /* ChatBarrOperation.m in Sources */, | |
| 1725 | 1782 | 810B65011E779B1F00133E15 /* MASLayoutConstraint.m in Sources */, |
| 1726 | 1783 | D2029CCE1E6EADE10027CD92 /* SearchRecomListModel.m in Sources */, |
| 1727 | 1784 | D2029CA11E6EADE10027CD92 /* NSString+MJExtension.m in Sources */, |
| ... | ... | @@ -1760,6 +1817,7 @@ |
| 1760 | 1817 | D2029CC61E6EADE10027CD92 /* SSKeychain.m in Sources */, |
| 1761 | 1818 | D2029C8B1E6EADE10027CD92 /* AFURLResponseSerialization.m in Sources */, |
| 1762 | 1819 | D2029C921E6EADE10027CD92 /* UIImageView+AFNetworking.m in Sources */, |
| 1820 | + D224B1971E826ED800CC61D0 /* ChatBarrageAnimAction.m in Sources */, | |
| 1763 | 1821 | D2029C9E1E6EADE10027CD92 /* NSObject+MJCoding.m in Sources */, |
| 1764 | 1822 | D2029C991E6EADE10027CD92 /* MJFoundation.m in Sources */, |
| 1765 | 1823 | D2575C461E76857100E3A8FC /* LVCAnimationManager.m in Sources */, |
| ... | ... | @@ -1767,13 +1825,13 @@ |
| 1767 | 1825 | D2029D041E6EAE2E0027CD92 /* UILabel+ContentSize.m in Sources */, |
| 1768 | 1826 | D25530031E79115100DF38A5 /* AnimQueueManager.m in Sources */, |
| 1769 | 1827 | D2029C871E6EADE10027CD92 /* AFHTTPSessionManager.m in Sources */, |
| 1770 | - D236968D1E7FC7C200E4BF71 /* CNBarrageManager.m in Sources */, | |
| 1771 | 1828 | D2029B861E6EAAA50027CD92 /* main.m in Sources */, |
| 1772 | 1829 | D2029C8C1E6EADE10027CD92 /* AFURLSessionManager.m in Sources */, |
| 1773 | 1830 | D2029C9F1E6EADE10027CD92 /* NSObject+MJKeyValue.m in Sources */, |
| 1774 | 1831 | D25BF8A01E80C4BD007FB138 /* UIImage+LVCVagueImage.m in Sources */, |
| 1775 | 1832 | D2888DB11E6EC05F003A77C8 /* TempViewController.m in Sources */, |
| 1776 | 1833 | 810B65021E779B1F00133E15 /* MASViewAttribute.m in Sources */, |
| 1834 | + D2B7B2511E8247D400ED084E /* ChatBarrageManager.m in Sources */, | |
| 1777 | 1835 | D2029CAC1E6EADE10027CD92 /* MJRefreshBackStateFooter.m in Sources */, |
| 1778 | 1836 | D2029CB11E6EADE10027CD92 /* MJRefreshConst.m in Sources */, |
| 1779 | 1837 | D2029CAD1E6EADE10027CD92 /* MJRefreshGifHeader.m in Sources */, |
| ... | ... | @@ -1787,6 +1845,7 @@ |
| 1787 | 1845 | 810B65041E779B1F00133E15 /* NSArray+MASAdditions.m in Sources */, |
| 1788 | 1846 | D25BF8801E7BD266007FB138 /* LVCUGCLivePlayerController.m in Sources */, |
| 1789 | 1847 | D2029D031E6EAE2E0027CD92 /* UIImage+ZXExtension.m in Sources */, |
| 1848 | + D24571581E8393EB00AA85D6 /* UIImageView+ZXExtension.m in Sources */, | |
| 1790 | 1849 | D2029D0A1E6EAE2E0027CD92 /* ZXServerUrl.m in Sources */, |
| 1791 | 1850 | D2029CCA1E6EADE10027CD92 /* SVProgressHUD.m in Sources */, |
| 1792 | 1851 | D2029CA81E6EADE10027CD92 /* MJRefreshAutoNormalFooter.m in Sources */, |
| ... | ... | @@ -1794,14 +1853,16 @@ |
| 1794 | 1853 | D217A24A1E7B76C7003B44CB /* PresentView.m in Sources */, |
| 1795 | 1854 | D22830F11E778C0F00627701 /* LiveBaseView.m in Sources */, |
| 1796 | 1855 | D2029CBA1E6EADE10027CD92 /* SDWebImageDecoder.m in Sources */, |
| 1856 | + D207BE9E1E84BD68006A0CE8 /* BarrageManager.m in Sources */, | |
| 1797 | 1857 | 8112D4311E7927A5002E00F6 /* LVCPlayerLoadingView.m in Sources */, |
| 1798 | 1858 | D2029D081E6EAE2E0027CD92 /* ZXDeviceInfo.m in Sources */, |
| 1859 | + D24571631E83C40B00AA85D6 /* PrivateView.m in Sources */, | |
| 1799 | 1860 | D2029CC21E6EADE10027CD92 /* UIImage+WebP.m in Sources */, |
| 1800 | 1861 | D2029BCD1E6EADD70027CD92 /* BaseViewController.m in Sources */, |
| 1801 | 1862 | 810B64E01E779AE900133E15 /* LVCPlayer.m in Sources */, |
| 1802 | 1863 | 810B64FF1E779B1F00133E15 /* MASConstraint.m in Sources */, |
| 1803 | - D236968E1E7FC7C200E4BF71 /* CNBarrageView.m in Sources */, | |
| 1804 | 1864 | D25BF87A1E7B8A82007FB138 /* FilterFunctionView.m in Sources */, |
| 1865 | + D207BEA11E84C1EC006A0CE8 /* AnimationBaseView.m in Sources */, | |
| 1805 | 1866 | D2029D001E6EAE2E0027CD92 /* NSNumber+ScaleHeight.m in Sources */, |
| 1806 | 1867 | D2888D9E1E6EBF1B003A77C8 /* LVCLiveViewController.m in Sources */, |
| 1807 | 1868 | D2029C951E6EADE10027CD92 /* UIWebView+AFNetworking.m in Sources */, |
| ... | ... | @@ -1817,10 +1878,12 @@ |
| 1817 | 1878 | D2029CCF1E6EADE10027CD92 /* SearchHttp.m in Sources */, |
| 1818 | 1879 | 810B65001E779B1F00133E15 /* MASConstraintMaker.m in Sources */, |
| 1819 | 1880 | D2029C881E6EADE10027CD92 /* AFNetworkReachabilityManager.m in Sources */, |
| 1881 | + D245715C1E83A62B00AA85D6 /* BounceView.m in Sources */, | |
| 1820 | 1882 | D2029D021E6EAE2E0027CD92 /* UIImage+ScaleImageSize.m in Sources */, |
| 1821 | 1883 | D2029BCC1E6EADD70027CD92 /* BaseView.m in Sources */, |
| 1822 | 1884 | D2888D941E6EB8B4003A77C8 /* LVCTabBar.m in Sources */, |
| 1823 | 1885 | D2888DB41E6EC154003A77C8 /* HomeViewController.m in Sources */, |
| 1886 | + D2B7B2541E824B2D00ED084E /* ChatBarrageView.m in Sources */, | |
| 1824 | 1887 | D25530061E7911A800DF38A5 /* GiftAnimationAction.m in Sources */, |
| 1825 | 1888 | D2029CD41E6EADE70027CD92 /* HttpService.m in Sources */, |
| 1826 | 1889 | ); | ... | ... |
LiveVideoCloud/LiveVideoCloud/AppDelegate/AppDelegate.m
| ... | ... | @@ -24,9 +24,9 @@ |
| 24 | 24 | |
| 25 | 25 | [[CNLiveChatManager sharedCNLiveChatManager] initWithAppKey:AppKey appId:AppId]; |
| 26 | 26 | [[CNLiveChatManager sharedCNLiveChatManager] connectServerSuccess:^{ |
| 27 | - | |
| 27 | + NSLog(@"connectSuccess"); | |
| 28 | 28 | } error:^(CNLiveChatConnectErrorCode errors) { |
| 29 | - | |
| 29 | + NSLog(@"errors%ld",errors); | |
| 30 | 30 | }]; |
| 31 | 31 | |
| 32 | 32 | return YES; | ... | ... |
LiveVideoCloud/LiveVideoCloud/Classes/Helpers/Tools.h
| ... | ... | @@ -8,6 +8,8 @@ |
| 8 | 8 | |
| 9 | 9 | #import <Foundation/Foundation.h> |
| 10 | 10 | |
| 11 | +@class userInfoModel; | |
| 12 | + | |
| 11 | 13 | @interface Tools : NSObject |
| 12 | 14 | |
| 13 | 15 | |
| ... | ... | @@ -19,12 +21,15 @@ typedef NS_ENUM(NSInteger, ShowMessageType) {//消息背景类型 |
| 19 | 21 | /** |
| 20 | 22 | 弹出页 |
| 21 | 23 | |
| 22 | - @param message 出框展示消息 | |
| 23 | - @param imageName 弹出框内图片名称 | |
| 24 | - @param view 将弹出框添加到的视图 | |
| 25 | - @param showMessageType 背景类型 | |
| 26 | 24 | @param callBackBlock 弹出框消失时回调 |
| 27 | 25 | */ |
| 28 | -+ (void)showBouncedWithMessage:(NSString *_Nullable)message leftImageName:(NSString *_Nonnull)imageName toView:(UIView *_Nullable)view showMessageType:(ShowMessageType)showMessageType callBackBlock:(void (^ _Nullable)())callBackBlock; | |
| 26 | ++ (void)showBouncedWithModel:(userInfoModel *_Nullable)model callBackBlock:(void (^ _Nullable)(UIView * _Nullable bounceView))callBackBlock; | |
| 27 | + | |
| 28 | ++ (void)closeBouces; | |
| 29 | + | |
| 30 | ++ (NSString *_Nullable)dictionaryToJson:(NSDictionary *_Nullable)dic; | |
| 31 | + | |
| 32 | ++ (NSDictionary *_Nullable)dictionaryWithJsonString:(NSString *_Nullable)jsonString; | |
| 33 | + | |
| 29 | 34 | |
| 30 | 35 | @end | ... | ... |
LiveVideoCloud/LiveVideoCloud/Classes/Helpers/Tools.m
| ... | ... | @@ -7,77 +7,117 @@ |
| 7 | 7 | // |
| 8 | 8 | |
| 9 | 9 | #import "Tools.h" |
| 10 | +#import "BounceView.h" | |
| 11 | +#import "userInfoModel.h" | |
| 12 | + | |
| 13 | +@interface Tools () | |
| 14 | + | |
| 15 | + | |
| 16 | +@end | |
| 10 | 17 | |
| 11 | 18 | @implementation Tools |
| 12 | 19 | |
| 13 | 20 | /** |
| 14 | 21 | 弹出页 |
| 15 | 22 | |
| 16 | - @param message 出框展示消息 | |
| 17 | - @param imageName 弹出框内图片名称 | |
| 18 | - @param view 将弹出框添加到的视图 | |
| 19 | - @param showMessageType 背景类型 | |
| 20 | 23 | @param callBackBlock 弹出框消失时回调 |
| 21 | 24 | */ |
| 22 | -+ (void)showBouncedWithMessage:(NSString *_Nullable)message leftImageName:(NSString *_Nonnull)imageName toView:(UIView *_Nullable)view showMessageType:(ShowMessageType)showMessageType callBackBlock:(void (^ _Nullable)())callBackBlock | |
| 25 | ++ (void)showBouncedWithModel:(userInfoModel *)model callBackBlock:(void (^ _Nullable)(UIView * _Nullable bounceView))callBackBlock | |
| 23 | 26 | { |
| 24 | - UIImageView *toView = [[UIImageView alloc] initWithFrame:view.bounds]; | |
| 25 | - switch (showMessageType) { | |
| 26 | - case ShowMessageTypeClear: | |
| 27 | - { | |
| 28 | - | |
| 29 | - } | |
| 30 | - break; | |
| 31 | - case ShowMessageTypeBlack: | |
| 32 | - { | |
| 33 | - toView.image = [UIImage imageNamed:@"整屏黑蒙版"]; | |
| 34 | - } | |
| 35 | - break; | |
| 36 | - default: | |
| 37 | - break; | |
| 38 | - } | |
| 39 | - [view addSubview:toView]; | |
| 27 | + UIImageView *toView = [[UIImageView alloc] initWithFrame:[UIApplication sharedApplication].keyWindow.bounds];//keyWindow | |
| 28 | + toView.backgroundColor = [UIColor clearColor]; | |
| 29 | + toView.userInteractionEnabled = YES; | |
| 30 | + [[UIApplication sharedApplication].keyWindow addSubview:toView]; | |
| 31 | + // UITapGestureRecognizer *gesture = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapClick:)]; | |
| 40 | 32 | |
| 41 | - UIImageView *centerView = [[UIImageView alloc] initWithFrame:CGRectMake(100, SCREEN_HEIGHT, 150, 50)]; | |
| 42 | - centerView.centerX = toView.centerX; | |
| 43 | - centerView.image = [UIImage imageNamed:@"提示背景50"]; | |
| 44 | - [toView addSubview:centerView]; | |
| 45 | - | |
| 46 | - UIImageView *imageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:imageName]]; | |
| 47 | - imageView.width = imageView.width * 0.5; | |
| 48 | - imageView.height = imageView.height * 0.5; | |
| 49 | - imageView.centerY = centerView.height * 0.5; | |
| 50 | - [centerView addSubview:imageView]; | |
| 51 | - | |
| 52 | - UILabel *titleLabel = [[UILabel alloc] init]; | |
| 53 | - titleLabel.text = message; | |
| 54 | - titleLabel.textColor = [UIColor whiteColor]; | |
| 55 | - titleLabel.font = kTitleLabelFont; | |
| 56 | - titleLabel.frame = CGRectMake(5, 10, [titleLabel labelSize].width, [titleLabel labelSize].height); | |
| 57 | - titleLabel.centerY = centerView.height * 0.5; | |
| 58 | - CGFloat left =(centerView.width - [titleLabel labelSize].width - 5 - imageView.width) * 0.5; | |
| 59 | - imageView.left = left; | |
| 60 | - titleLabel.left = imageView.right + 5; | |
| 61 | - [centerView addSubview:titleLabel]; | |
| 62 | - | |
| 63 | - NSTimer *newTimer = [NSTimer timerWithTimeInterval:2.0 repeats:NO block:^(NSTimer * _Nonnull timer) { | |
| 64 | - [UIView animateWithDuration:0.75 animations:^{ | |
| 65 | - centerView.top = SCREEN_HEIGHT; | |
| 66 | - | |
| 67 | - } completion:^(BOOL finished) { | |
| 68 | - [toView removeFromSuperview]; | |
| 69 | - [centerView removeFromSuperview]; | |
| 70 | - callBackBlock(); | |
| 71 | - }]; | |
| 72 | - }]; | |
| 73 | - [[NSRunLoop currentRunLoop] addTimer:newTimer forMode:NSRunLoopCommonModes]; | |
| 74 | - | |
| 75 | - [UIView animateWithDuration:0.75 animations:^{ | |
| 76 | - centerView.centerY = toView.centerY; | |
| 33 | + BounceView *bounceView = [BounceView bounceView]; | |
| 34 | + bounceView.model = model; | |
| 35 | + bounceView.centerX = toView.centerX; | |
| 36 | + [toView addSubview:bounceView]; | |
| 37 | + | |
| 38 | + [UIView animateWithDuration:0.5 animations:^{ | |
| 39 | + bounceView.centerY = toView.centerY; | |
| 77 | 40 | |
| 78 | 41 | } completion:^(BOOL finished) { |
| 42 | + callBackBlock(bounceView); | |
| 43 | + }]; | |
| 44 | +} | |
| 45 | + | |
| 46 | + | |
| 47 | +//+ (void)btnClick | |
| 48 | +//{ | |
| 49 | +// NSLog(@"btnClick"); | |
| 50 | +//// BounceView *bounceView = [BounceView bounceView]; | |
| 51 | +//// [UIView animateWithDuration:0.25 animations:^{ | |
| 52 | +//// bounceView.top = SCREEN_HEIGHT; | |
| 53 | +//// | |
| 54 | +//// } completion:^(BOOL finished) { | |
| 55 | +//// [bounceView.superview removeFromSuperview]; | |
| 56 | +//// [bounceView removeFromSuperview]; | |
| 57 | +//// }]; | |
| 58 | +//} | |
| 59 | + | |
| 60 | +//+ (void)tapClick:(UITapGestureRecognizer *)gesture | |
| 61 | +//{ | |
| 62 | +// NSLog(@"taptaptaptaptap"); | |
| 63 | +// UIView *view = gesture.view; | |
| 64 | +//// if (view.tag == 1000 && [view isKindOfClass:[UIImageView class]]) { | |
| 65 | +// [UIView animateWithDuration:0.25 animations:^{ | |
| 66 | +// gesture.view.top = SCREEN_HEIGHT; | |
| 67 | +// | |
| 68 | +// } completion:^(BOOL finished) { | |
| 69 | +// [gesture.view removeFromSuperview]; | |
| 70 | +// }]; | |
| 71 | +//// } | |
| 72 | +//} | |
| 73 | + | |
| 74 | ++ (void)closeBouces | |
| 75 | +{ | |
| 76 | + BounceView *bounceView = [BounceView bounceView]; | |
| 77 | + [UIView animateWithDuration:0.25 animations:^{ | |
| 78 | + bounceView.top = SCREEN_HEIGHT; | |
| 79 | 79 | |
| 80 | + } completion:^(BOOL finished) { | |
| 81 | + [bounceView.superview removeFromSuperview]; | |
| 82 | + [bounceView removeFromSuperview]; | |
| 80 | 83 | }]; |
| 81 | 84 | } |
| 82 | 85 | |
| 86 | +/** | |
| 87 | + 把字典转换成格式化的JSON格式的字符串 | |
| 88 | + | |
| 89 | + @param dic 字典 | |
| 90 | + @return JSON格式的字符串 | |
| 91 | + */ | |
| 92 | ++ (NSString *_Nullable)dictionaryToJson:(NSDictionary *_Nullable)dic | |
| 93 | +{ | |
| 94 | + NSError *parseError = nil; | |
| 95 | + NSData *jsonData = [NSJSONSerialization dataWithJSONObject:dic options:NSJSONWritingPrettyPrinted error:&parseError]; | |
| 96 | + return [[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding]; | |
| 97 | +} | |
| 98 | + | |
| 99 | +/** | |
| 100 | + 把格式化的JSON格式的字符串转换成字典 | |
| 101 | + | |
| 102 | + @param jsonString JSON格式的字符串 | |
| 103 | + @return 返回字典 | |
| 104 | + */ | |
| 105 | ++ (NSDictionary *_Nullable)dictionaryWithJsonString:(NSString *_Nullable)jsonString { | |
| 106 | + if (jsonString == nil) { | |
| 107 | + return nil; | |
| 108 | + } | |
| 109 | + | |
| 110 | + NSData *jsonData = [jsonString dataUsingEncoding:NSUTF8StringEncoding]; | |
| 111 | + NSError *err; | |
| 112 | + NSDictionary *dic = [NSJSONSerialization JSONObjectWithData:jsonData | |
| 113 | + options:NSJSONReadingMutableContainers | |
| 114 | + error:&err]; | |
| 115 | + if(err) { | |
| 116 | + NSLog(@"json解析失败:%@",err); | |
| 117 | + return nil; | |
| 118 | + } | |
| 119 | + return dic; | |
| 120 | +} | |
| 121 | + | |
| 122 | + | |
| 83 | 123 | @end | ... | ... |
LiveVideoCloud/LiveVideoCloud/Classes/Sections/InteractionSections/AnimationBaseView.h
0 → 100644
| 1 | +// | |
| 2 | +// AnimationBaseView.h | |
| 3 | +// LiveVideoCloud | |
| 4 | +// | |
| 5 | +// Created by 张旭 on 2017/3/24. | |
| 6 | +// Copyright © 2017年 cnlive. All rights reserved. | |
| 7 | +// | |
| 8 | + | |
| 9 | +#import <UIKit/UIKit.h> | |
| 10 | +#import "ChatBarrageView.h" | |
| 11 | + | |
| 12 | +@protocol TouchPointDelegate <NSObject> | |
| 13 | + | |
| 14 | +- (void)touchPoint:(CGPoint)touchPoint; | |
| 15 | + | |
| 16 | +@end | |
| 17 | + | |
| 18 | +@interface AnimationBaseView : UIView | |
| 19 | +@property (nonatomic ,assign) BOOL isBarrage;//是否在执行动画 | |
| 20 | +@property (nonatomic ,strong) ChatBarrageView * _Nullable barrageView; | |
| 21 | +@property (nonatomic)_Nonnull id <TouchPointDelegate> delegate; | |
| 22 | + | |
| 23 | + | |
| 24 | +@end | ... | ... |
LiveVideoCloud/LiveVideoCloud/Classes/Sections/InteractionSections/AnimationBaseView.m
0 → 100644
| 1 | +// | |
| 2 | +// AnimationBaseView.m | |
| 3 | +// LiveVideoCloud | |
| 4 | +// | |
| 5 | +// Created by 张旭 on 2017/3/24. | |
| 6 | +// Copyright © 2017年 cnlive. All rights reserved. | |
| 7 | +// | |
| 8 | + | |
| 9 | +#import "AnimationBaseView.h" | |
| 10 | +#import "ChatBarrageView.h" | |
| 11 | + | |
| 12 | +@implementation AnimationBaseView | |
| 13 | + | |
| 14 | +- (instancetype)initWithFrame:(CGRect)frame | |
| 15 | +{ | |
| 16 | + if (self = [super initWithFrame:frame]) { | |
| 17 | + self.backgroundColor = [UIColor redColor]; | |
| 18 | + self.clipsToBounds = YES; | |
| 19 | + } | |
| 20 | + return self; | |
| 21 | +} | |
| 22 | + | |
| 23 | +- (UIView *)hitTest:(CGPoint)point withEvent:(UIEvent *)event { | |
| 24 | + UIView *view = [super hitTest:point withEvent:event]; | |
| 25 | + | |
| 26 | +// for (UIView *v in [UIApplication sharedApplication].keyWindow.subviews) { | |
| 27 | +// if (v.tag == 1000) { | |
| 28 | +// NSLog(@"添加过了"); | |
| 29 | +// return view; | |
| 30 | +// } | |
| 31 | +// } | |
| 32 | + if (self.isBarrage) { | |
| 33 | + NSLog(@"point:%@\n",NSStringFromCGPoint(point)); | |
| 34 | + | |
| 35 | + if ([self.delegate respondsToSelector:@selector(touchPoint:)]) { | |
| 36 | + [self.delegate touchPoint:point]; | |
| 37 | + } | |
| 38 | + } | |
| 39 | + return view; | |
| 40 | +} | |
| 41 | + | |
| 42 | + | |
| 43 | +/* | |
| 44 | +// Only override drawRect: if you perform custom drawing. | |
| 45 | +// An empty implementation adversely affects performance during animation. | |
| 46 | +- (void)drawRect:(CGRect)rect { | |
| 47 | + // Drawing code | |
| 48 | +} | |
| 49 | +*/ | |
| 50 | + | |
| 51 | +@end | ... | ... |
LiveVideoCloud/LiveVideoCloud/Classes/Sections/InteractionSections/BottomToolView/BottomToolView.m
| ... | ... | @@ -71,8 +71,8 @@ |
| 71 | 71 | { |
| 72 | 72 | UIButton *privateChatBtn = [UIButton buttonWithType:UIButtonTypeCustom]; |
| 73 | 73 | privateChatBtn.frame = CGRectMake(self.width*0.5 - 50, (self.height - 45)*0.5, 45, 45); |
| 74 | - [privateChatBtn setBackgroundImage:[UIImage imageNamed:@"LiveChatNormal"] forState:UIControlStateNormal]; | |
| 75 | - [privateChatBtn setBackgroundImage:[UIImage imageNamed:@"LiveChatTouch"] forState:UIControlStateHighlighted]; | |
| 74 | + [privateChatBtn setBackgroundImage:[UIImage imageNamed:@"privateChat.png"] forState:UIControlStateNormal]; | |
| 75 | + [privateChatBtn setBackgroundImage:[UIImage imageNamed:@"privateChat.png"] forState:UIControlStateHighlighted]; | |
| 76 | 76 | [privateChatBtn addTarget:self action:@selector(privateChatAction) forControlEvents:UIControlEventTouchUpInside]; |
| 77 | 77 | _privateChatBtn = privateChatBtn; |
| 78 | 78 | } | ... | ... |
LiveVideoCloud/LiveVideoCloud/Classes/Sections/InteractionSections/BounceView.h
0 → 100644
| 1 | +// | |
| 2 | +// BounceView.h | |
| 3 | +// LiveVideoCloud | |
| 4 | +// | |
| 5 | +// Created by 张旭 on 2017/3/23. | |
| 6 | +// Copyright © 2017年 cnlive. All rights reserved. | |
| 7 | +// | |
| 8 | + | |
| 9 | +#import <UIKit/UIKit.h> | |
| 10 | +@class userInfoModel; | |
| 11 | + | |
| 12 | +@interface BounceView : UIView | |
| 13 | + | |
| 14 | ++ (instancetype _Nullable)bounceView; | |
| 15 | + | |
| 16 | +@property (nonatomic ,strong) userInfoModel * _Nullable model; | |
| 17 | + | |
| 18 | +@end | ... | ... |
LiveVideoCloud/LiveVideoCloud/Classes/Sections/InteractionSections/BounceView.m
0 → 100644
| 1 | +// | |
| 2 | +// BounceView.m | |
| 3 | +// LiveVideoCloud | |
| 4 | +// | |
| 5 | +// Created by 张旭 on 2017/3/23. | |
| 6 | +// Copyright © 2017年 cnlive. All rights reserved. | |
| 7 | +// | |
| 8 | + | |
| 9 | +#import "BounceView.h" | |
| 10 | +#import "userInfoModel.h" | |
| 11 | + | |
| 12 | +@interface BounceView () | |
| 13 | + | |
| 14 | +@property (nonatomic ,strong) UIImageView * _Nullable icon;//头像 | |
| 15 | +@property (nonatomic ,strong) UILabel * _Nullable nameLbl;//名字 | |
| 16 | +@property (nonatomic ,strong) UILabel * _Nullable signLbl;//签名 | |
| 17 | +@property (nonatomic ,strong) UIButton * _Nullable closeBtn;//关闭 | |
| 18 | +@property (nonatomic ,strong) UIButton * _Nullable privateChatBtn;//私信 | |
| 19 | +@property (nonatomic ,strong) UIButton * _Nullable aiteHeBtn;//@他 | |
| 20 | +@property (nonatomic ,strong) UIButton * _Nullable homeBtn;//主页 | |
| 21 | + | |
| 22 | +@end | |
| 23 | + | |
| 24 | +@implementation BounceView | |
| 25 | + | |
| 26 | ++ (instancetype _Nullable)bounceView | |
| 27 | +{ | |
| 28 | + static BounceView *bounceView; | |
| 29 | + | |
| 30 | + static dispatch_once_t onceToken; | |
| 31 | + dispatch_once(&onceToken, ^{ | |
| 32 | + bounceView = [[BounceView alloc] initWithFrame:CGRectMake(100, SCREEN_HEIGHT, SCREEN_WIDTH - 80, 300)]; | |
| 33 | + }); | |
| 34 | + return bounceView; | |
| 35 | +} | |
| 36 | + | |
| 37 | +- (instancetype)initWithFrame:(CGRect)frame | |
| 38 | +{ | |
| 39 | + if (self = [super initWithFrame:frame]) { | |
| 40 | + | |
| 41 | + self.backgroundColor = [UIColor whiteColor]; | |
| 42 | + [self addSubview:self.signLbl]; | |
| 43 | + [self addSubview:self.closeBtn]; | |
| 44 | + [self addSubview:self.homeBtn]; | |
| 45 | + } | |
| 46 | + return self; | |
| 47 | +} | |
| 48 | + | |
| 49 | +- (void)setModel:(userInfoModel *)model | |
| 50 | +{ | |
| 51 | + _model = model; | |
| 52 | + [self.icon zx_setHeader:model.icon]; | |
| 53 | + self.nameLbl.text = model.name; | |
| 54 | + self.signLbl.text = model.sign; | |
| 55 | + self.signLbl.frame = CGRectMake(self.signLbl.left, self.signLbl.top, [self.signLbl labelSize].width, [self.signLbl labelSize].height); | |
| 56 | + self.signLbl.centerX = self.width * 0.5; | |
| 57 | + self.nameLbl.centerX = _icon.centerX; | |
| 58 | +} | |
| 59 | + | |
| 60 | +- (void)closeClick | |
| 61 | +{ | |
| 62 | + [Tools closeBouces]; | |
| 63 | +} | |
| 64 | + | |
| 65 | +- (void)aiteHeBtnClick | |
| 66 | +{ | |
| 67 | + NSLog(@"aiteHeBtnClick"); | |
| 68 | +} | |
| 69 | + | |
| 70 | +- (void)privateChatClick | |
| 71 | +{ | |
| 72 | + NSLog(@"privateChatClick"); | |
| 73 | +} | |
| 74 | + | |
| 75 | +- (void)homeBtnClick | |
| 76 | +{ | |
| 77 | + NSLog(@"homeBtnClick"); | |
| 78 | +} | |
| 79 | + | |
| 80 | +- (UIImageView *)icon | |
| 81 | +{ | |
| 82 | + if (!_icon) | |
| 83 | + { | |
| 84 | + _icon = [[UIImageView alloc] initWithFrame:CGRectMake(10, 20, 40, 40)]; | |
| 85 | + _icon.centerX = self.width * 0.5; | |
| 86 | + [self addSubview:_icon]; | |
| 87 | + } | |
| 88 | + return _icon; | |
| 89 | +} | |
| 90 | + | |
| 91 | +- (UILabel *)signLbl | |
| 92 | +{ | |
| 93 | + if (!_signLbl) | |
| 94 | + { | |
| 95 | + _signLbl = [[UILabel alloc] initWithFrame:CGRectMake(self.nameLbl.left, self.nameLbl.bottom + 10 , self.width - 20, 20)]; | |
| 96 | + _signLbl.centerX = _icon.centerX; | |
| 97 | + _signLbl.text = @"TA很懒,什么都没有留下。"; | |
| 98 | + _signLbl.numberOfLines = 0; | |
| 99 | + _signLbl.textAlignment = NSTextAlignmentCenter; | |
| 100 | + _signLbl.font = [UIFont systemFontOfSize:kContentFont]; | |
| 101 | + } | |
| 102 | + return _signLbl; | |
| 103 | +} | |
| 104 | + | |
| 105 | +- (UILabel *)nameLbl | |
| 106 | +{ | |
| 107 | + if (!_nameLbl) | |
| 108 | + { | |
| 109 | + _nameLbl = [[UILabel alloc] initWithFrame:CGRectMake(self.icon.left, self.icon.bottom + 10 , self.width - 20, 20)]; | |
| 110 | + _nameLbl.centerX = _icon.centerX; | |
| 111 | + _nameLbl.text = @"姓名"; | |
| 112 | + _nameLbl.textAlignment = NSTextAlignmentCenter; | |
| 113 | + _nameLbl.font = [UIFont systemFontOfSize:kContentFont]; | |
| 114 | + [self addSubview:_nameLbl]; | |
| 115 | + } | |
| 116 | + return _nameLbl; | |
| 117 | +} | |
| 118 | + | |
| 119 | +- (UIButton *)closeBtn | |
| 120 | +{ | |
| 121 | + if (!_closeBtn) | |
| 122 | + { | |
| 123 | + _closeBtn = [[UIButton alloc] initWithFrame:CGRectMake(self.width - 50, 10, 40, 40)]; | |
| 124 | + [_closeBtn addTarget:self action:@selector(closeClick) forControlEvents:UIControlEventTouchUpInside]; | |
| 125 | + [_closeBtn setBackgroundImage:[UIImage imageNamed:@"LiveCloseNormal"] forState:UIControlStateNormal]; | |
| 126 | + } | |
| 127 | + return _closeBtn; | |
| 128 | +} | |
| 129 | + | |
| 130 | +- (UIButton *)privateChatBtn | |
| 131 | +{ | |
| 132 | + if (!_privateChatBtn) | |
| 133 | + { | |
| 134 | + _privateChatBtn = [[UIButton alloc] initWithFrame:CGRectMake(0, self.height - 50, self.width / 3.0, 50)]; | |
| 135 | + [_privateChatBtn addTarget:self action:@selector(privateChatClick) forControlEvents:UIControlEventTouchUpInside]; | |
| 136 | + [_privateChatBtn setTitle:@"私信" forState:UIControlStateNormal]; | |
| 137 | + [_privateChatBtn setTitleColor:[UIColor cyanColor] forState:UIControlStateNormal]; | |
| 138 | + [self addSubview:_privateChatBtn]; | |
| 139 | + } | |
| 140 | + return _privateChatBtn; | |
| 141 | +} | |
| 142 | + | |
| 143 | +- (UIButton *)aiteHeBtn | |
| 144 | +{ | |
| 145 | + if (!_aiteHeBtn) | |
| 146 | + { | |
| 147 | + _aiteHeBtn = [[UIButton alloc] initWithFrame:CGRectMake(self.privateChatBtn.right, self.height - self.privateChatBtn.height, self.width / 3.0, self.privateChatBtn.height)]; | |
| 148 | + [_aiteHeBtn addTarget:self action:@selector(aiteHeBtnClick) forControlEvents:UIControlEventTouchUpInside]; | |
| 149 | + [_aiteHeBtn setTitle:@"@TA" forState:UIControlStateNormal]; | |
| 150 | + [_aiteHeBtn setTitleColor:[UIColor cyanColor] forState:UIControlStateNormal]; | |
| 151 | + [self addSubview:_aiteHeBtn]; | |
| 152 | + } | |
| 153 | + return _aiteHeBtn; | |
| 154 | +} | |
| 155 | + | |
| 156 | +- (UIButton *)homeBtn | |
| 157 | +{ | |
| 158 | + if (!_homeBtn) | |
| 159 | + { | |
| 160 | + _homeBtn = [[UIButton alloc] initWithFrame:CGRectMake(self.aiteHeBtn.right, self.height - self.privateChatBtn.height, self.width / 3.0, self.privateChatBtn.height)]; | |
| 161 | + [_homeBtn addTarget:self action:@selector(homeBtnClick) forControlEvents:UIControlEventTouchUpInside]; | |
| 162 | + [_homeBtn setTitle:@"主页" forState:UIControlStateNormal]; | |
| 163 | + [_homeBtn setTitleColor:[UIColor cyanColor] forState:UIControlStateNormal]; | |
| 164 | + } | |
| 165 | + return _homeBtn; | |
| 166 | +} | |
| 167 | + | |
| 168 | +/* | |
| 169 | +// Only override drawRect: if you perform custom drawing. | |
| 170 | +// An empty implementation adversely affects performance during animation. | |
| 171 | +- (void)drawRect:(CGRect)rect { | |
| 172 | + // Drawing code | |
| 173 | +} | |
| 174 | +*/ | |
| 175 | + | |
| 176 | +@end | ... | ... |
LiveVideoCloud/LiveVideoCloud/Classes/Sections/InteractionSections/Chat/Barrage/CNBarrageManager.h deleted
100644 → 0
| 1 | -// | |
| 2 | -// CNBarrageManager.h | |
| 3 | -// personalXmppChatDemo | |
| 4 | -// | |
| 5 | -// Created by 张旭 on 2016/12/10. | |
| 6 | -// Copyright © 2016年 cnlive. All rights reserved. | |
| 7 | -// | |
| 8 | - | |
| 9 | -#import <Foundation/Foundation.h> | |
| 10 | - | |
| 11 | -@class CNBarrageView; | |
| 12 | -@class chatMsgModel; | |
| 13 | -@interface CNBarrageManager : NSObject | |
| 14 | - | |
| 15 | -@property (nonatomic, copy) void(^generateBarrageBlock)(CNBarrageView *view);//生成弹幕View回调 | |
| 16 | -@property (nonatomic) BOOL isStopBarrage;//是否关闭了弹幕 | |
| 17 | -/** | |
| 18 | - 开始弹幕根据新消息数组 | |
| 19 | - | |
| 20 | - @param newBarrageArray 新消息数组 | |
| 21 | - */ | |
| 22 | -- (void)startBarrageWithNewArray:(NSMutableArray <chatMsgModel *>*)newBarrageArray; | |
| 23 | - | |
| 24 | -/** | |
| 25 | - 停止弹幕 | |
| 26 | - */ | |
| 27 | -- (void)stopBarrage; | |
| 28 | - | |
| 29 | - | |
| 30 | - | |
| 31 | -@end |
LiveVideoCloud/LiveVideoCloud/Classes/Sections/InteractionSections/Chat/Barrage/CNBarrageManager.m deleted
100644 → 0
| 1 | -// | |
| 2 | -// CNBarrageManager.m | |
| 3 | -// personalXmppChatDemo | |
| 4 | -// | |
| 5 | -// Created by 张旭 on 2016/12/10. | |
| 6 | -// Copyright © 2016年 cnlive. All rights reserved. | |
| 7 | -// | |
| 8 | - | |
| 9 | -#import "CNBarrageManager.h" | |
| 10 | -#import "CNBarrageView.h" | |
| 11 | -#import "chatMsgModel.h" | |
| 12 | - | |
| 13 | -#define MAX_OVERLAP_COUNT 100 | |
| 14 | - | |
| 15 | -@interface CNBarrageManager () | |
| 16 | - | |
| 17 | -@property (nonatomic, strong) NSMutableArray *_Nullable allComments;//所有评论 | |
| 18 | -@property (nonatomic, strong) NSMutableArray *_Nullable tmpComments;//临时评论 | |
| 19 | -@property (nonatomic ,strong) NSMutableArray *_Nullable barrageQueue;//评论管理队列数组 | |
| 20 | -@property (nonatomic ,strong) NSMutableArray *_Nullable trajectoryArr;//弹幕轨迹数组 | |
| 21 | - | |
| 22 | -@property BOOL isStarted;//标记是否开始弹幕 | |
| 23 | -@property BOOL isStopAnimation;//标记是否停止弹幕 | |
| 24 | - | |
| 25 | -@end | |
| 26 | - | |
| 27 | -@implementation CNBarrageManager | |
| 28 | - | |
| 29 | -/** | |
| 30 | - 开始弹幕根据新消息数组 | |
| 31 | - | |
| 32 | - @param newBarrageArray 新消息数组 | |
| 33 | - */ | |
| 34 | -- (void)startBarrageWithNewArray:(NSMutableArray <chatMsgModel *>*)newBarrageArray | |
| 35 | -{ | |
| 36 | - if (self.isStopAnimation && _isStopBarrage) { | |
| 37 | - return; | |
| 38 | - } | |
| 39 | - [self.allComments addObjectsFromArray:newBarrageArray]; | |
| 40 | - | |
| 41 | - [self startBarrage]; | |
| 42 | -} | |
| 43 | - | |
| 44 | -/** | |
| 45 | - 开始弹幕 | |
| 46 | - */ | |
| 47 | -- (void)startBarrage | |
| 48 | -{ | |
| 49 | - if (self.tmpComments.count == 0) { | |
| 50 | - [self.tmpComments addObjectsFromArray:self.allComments]; | |
| 51 | - [self.allComments removeAllObjects]; | |
| 52 | - } | |
| 53 | - | |
| 54 | - self.isStarted = YES; | |
| 55 | - self.isStopAnimation = NO; | |
| 56 | - [self initBarrageCommentView]; | |
| 57 | -} | |
| 58 | - | |
| 59 | -/** | |
| 60 | - 停止弹幕 | |
| 61 | - */ | |
| 62 | -- (void)stopBarrage | |
| 63 | -{ | |
| 64 | - self.isStopAnimation = YES; | |
| 65 | - | |
| 66 | - [self.barrageQueue enumerateObjectsUsingBlock:^(id _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) { | |
| 67 | - CNBarrageView *view = obj; | |
| 68 | - [view stopAnimation]; | |
| 69 | - view = nil; | |
| 70 | - self.tmpComments = nil; | |
| 71 | - self.allComments = nil; | |
| 72 | - self.trajectoryArr = nil; | |
| 73 | - }]; | |
| 74 | - self.barrageQueue = nil; | |
| 75 | -} | |
| 76 | - | |
| 77 | -/** | |
| 78 | - 初始化弹幕的评论View | |
| 79 | - */ | |
| 80 | -- (void)initBarrageCommentView | |
| 81 | -{ | |
| 82 | - if(self.isStopAnimation)return; | |
| 83 | - //初始化轨道位置随机 | |
| 84 | - long count = self.tmpComments.count; | |
| 85 | - for (int i = 0; i < count; i ++) { | |
| 86 | - chatMsgModel *model = [self.tmpComments firstObject]; | |
| 87 | - NSString *comment = model.content; | |
| 88 | - NSString *userName = model.name; | |
| 89 | - if (comment) { | |
| 90 | - [self.tmpComments removeObjectAtIndex:0]; | |
| 91 | - //根据当前未发送弹幕数量生成轨迹 | |
| 92 | - NSString *trajectory; | |
| 93 | - if (self.tmpComments.count > MAX_OVERLAP_COUNT) | |
| 94 | - {//数量较多轨迹可重叠 | |
| 95 | - trajectory = [self trajectoryOverlap:YES]; | |
| 96 | - }else | |
| 97 | - {//数量较少轨迹可能不重叠,但频率高会使轨迹数组已满,造成重叠 | |
| 98 | - trajectory = [self trajectoryOverlap:NO]; | |
| 99 | - } | |
| 100 | - [self createBarrageComment:comment userName:userName trajectory:trajectory isMine:model.isMine]; //trajectory:trajectory isMine:model.isMine]; | |
| 101 | - } | |
| 102 | - else { | |
| 103 | - //当弹幕没有时跳出循环 | |
| 104 | - break; | |
| 105 | - } | |
| 106 | - } | |
| 107 | -} | |
| 108 | - | |
| 109 | -/** | |
| 110 | - 生成评论弹幕轨迹 | |
| 111 | - | |
| 112 | - @param isOverlap 是否重叠 | |
| 113 | - @return 根据轨迹是否可重叠,生成对应的新轨迹 | |
| 114 | - */ | |
| 115 | -- (NSString *)trajectoryOverlap:(BOOL)isOverlap | |
| 116 | -{ | |
| 117 | - NSString *trajectory = @""; | |
| 118 | - long arcIndex = arc4random() % MAX_BARRAGE_VERTICAL_COUNT; | |
| 119 | - CGFloat tra = arcIndex * BARRAGE_VERTICAL_HEIGHT + (arcIndex - 1) * BARRAGE_VERTICAL_MARGIN; | |
| 120 | -// NSLog(@"trajectory = %f ,%ld,%f,%ld,%f",tra,arcIndex,BARRAGE_VERTICAL_MARGIN,MAX_BARRAGE_VERTICAL_COUNT,BARRAGE_VERTICAL_MARGIN); | |
| 121 | - if (isOverlap) { | |
| 122 | - //生成可重叠的轨迹 | |
| 123 | - trajectory = [NSString stringWithFormat:@"%f",tra]; | |
| 124 | - [self.trajectoryArr addObject:trajectory]; | |
| 125 | - return [NSString stringWithFormat:@"%f",tra]; | |
| 126 | - } | |
| 127 | - //生成不重叠的轨迹 | |
| 128 | - do { | |
| 129 | - arcIndex = arc4random() % MAX_BARRAGE_VERTICAL_COUNT; | |
| 130 | - tra = arcIndex * BARRAGE_VERTICAL_HEIGHT + (arcIndex - 1) * BARRAGE_VERTICAL_MARGIN; | |
| 131 | - trajectory = [NSString stringWithFormat:@"%f",tra]; | |
| 132 | - if (self.trajectoryArr.count >= MAX_BARRAGE_VERTICAL_COUNT) break; | |
| 133 | - | |
| 134 | - } while ([self.trajectoryArr containsObject:trajectory]); | |
| 135 | - if (self.trajectoryArr.count >= MAX_BARRAGE_VERTICAL_COUNT) | |
| 136 | - {//当前轨迹数组已满,弹幕需要重叠显示 | |
| 137 | - | |
| 138 | - }else | |
| 139 | - {//当前轨迹数组还没满,弹幕无需重叠 | |
| 140 | - [self.trajectoryArr addObject:trajectory]; | |
| 141 | - } | |
| 142 | - return trajectory; | |
| 143 | -} | |
| 144 | - | |
| 145 | -/** | |
| 146 | - 下一条评论 | |
| 147 | - | |
| 148 | - @return 返回当前tmpComments的下一条评论数据 | |
| 149 | - */ | |
| 150 | -- (NSString *)nextComment { | |
| 151 | - chatMsgModel *model = [self.tmpComments firstObject]; | |
| 152 | - if (model.content) { | |
| 153 | - [self.tmpComments removeObjectAtIndex:0]; | |
| 154 | - } | |
| 155 | - return model.content; | |
| 156 | -} | |
| 157 | - | |
| 158 | -/** | |
| 159 | - 创建评论弹幕,根据评论内容和弹幕轨迹 | |
| 160 | - | |
| 161 | - @param comment 评论内容 | |
| 162 | - @param userName 用户名字 | |
| 163 | - @param trajectory 弹幕轨迹 | |
| 164 | - @param isMine 是否是我发的弹幕 | |
| 165 | - */ | |
| 166 | -- (void)createBarrageComment:(NSString *)comment userName:(NSString *)userName trajectory:(NSString *)trajectory isMine:(BOOL)isMine | |
| 167 | -{ | |
| 168 | - if (self.isStopAnimation) { | |
| 169 | - return; | |
| 170 | - } | |
| 171 | - //创建一个弹幕view | |
| 172 | - CNBarrageView *view = [[CNBarrageView alloc] initWithContent:comment userName:userName isMine:isMine]; | |
| 173 | - | |
| 174 | - //设置运行轨迹 | |
| 175 | - view.trajectory = [trajectory floatValue]; | |
| 176 | - weakself | |
| 177 | - __weak CNBarrageView *weakBarrageView = view; | |
| 178 | - view.moveBlock = ^(CommentMoveState status){ | |
| 179 | - strongself | |
| 180 | - if (self.isStopAnimation) { | |
| 181 | - return; | |
| 182 | - } | |
| 183 | - switch (status) { | |
| 184 | - case CommentMoveStateStart: | |
| 185 | - { | |
| 186 | - //弹幕开始,将view加入弹幕管理数组 | |
| 187 | - [self.barrageQueue addObject:weakBarrageView]; | |
| 188 | - } | |
| 189 | - break; | |
| 190 | - case CommentMoveStateEnter: | |
| 191 | - { | |
| 192 | - [self.trajectoryArr removeObject:trajectory]; | |
| 193 | - //弹幕完全进入屏幕,判断接下来是否还有内容,如果有则在该弹幕轨迹队列中创建弹幕 | |
| 194 | - NSString *comment = [self nextComment]; | |
| 195 | - if (comment) { | |
| 196 | - [self createBarrageComment:comment userName:userName trajectory:trajectory isMine:isMine]; | |
| 197 | -// [self createBarrageComment:comment trajectory:trajectory isMine:isMine]; | |
| 198 | - } | |
| 199 | - else { | |
| 200 | - //没有评论了 | |
| 201 | - } | |
| 202 | - } | |
| 203 | - break; | |
| 204 | - case CommentMoveStateEnd: | |
| 205 | - { | |
| 206 | - //弹幕飞出屏幕后从弹幕管理队列中删除 | |
| 207 | - if ([self.barrageQueue containsObject:weakBarrageView]) { | |
| 208 | - [self.barrageQueue removeObject:weakBarrageView]; | |
| 209 | - } | |
| 210 | - } | |
| 211 | - break; | |
| 212 | - default: | |
| 213 | - break; | |
| 214 | - } | |
| 215 | - }; | |
| 216 | - //弹幕生成后,传到Controller进行页面展示 | |
| 217 | - if (self.generateBarrageBlock) { | |
| 218 | - self.generateBarrageBlock(view); | |
| 219 | - } | |
| 220 | -} | |
| 221 | - | |
| 222 | -#pragma mark - getter | |
| 223 | - | |
| 224 | -- (NSMutableArray *)allComments { | |
| 225 | - if (!_allComments) { | |
| 226 | - _allComments = [NSMutableArray array]; | |
| 227 | - } | |
| 228 | - return _allComments; | |
| 229 | -} | |
| 230 | - | |
| 231 | -- (NSMutableArray *)tmpComments { | |
| 232 | - if (!_tmpComments) { | |
| 233 | - _tmpComments = [NSMutableArray array]; | |
| 234 | - } | |
| 235 | - return _tmpComments; | |
| 236 | -} | |
| 237 | - | |
| 238 | -- (NSMutableArray *)barrageQueue { | |
| 239 | - if (!_barrageQueue) { | |
| 240 | - _barrageQueue = [NSMutableArray array]; | |
| 241 | - } | |
| 242 | - return _barrageQueue; | |
| 243 | -} | |
| 244 | - | |
| 245 | -- (NSMutableArray *)trajectoryArr { | |
| 246 | - if (!_trajectoryArr) { | |
| 247 | - _trajectoryArr = [NSMutableArray array]; | |
| 248 | - } | |
| 249 | - return _trajectoryArr; | |
| 250 | -} | |
| 251 | - | |
| 252 | -@end |
LiveVideoCloud/LiveVideoCloud/Classes/Sections/InteractionSections/Chat/Barrage/CNBarrageView.h deleted
100644 → 0
| 1 | -// | |
| 2 | -// CNBarrageView.h | |
| 3 | -// personalXmppChatDemo | |
| 4 | -// | |
| 5 | -// Created by 张旭 on 2016/12/10. | |
| 6 | -// Copyright © 2016年 cnlive. All rights reserved. | |
| 7 | -// | |
| 8 | - | |
| 9 | -#import <UIKit/UIKit.h> | |
| 10 | - | |
| 11 | -#define BARRAGE_VERTICAL_HEIGHT 25.f //每个弹幕View在垂直方向上的高度 | |
| 12 | -#define MAX_BARRAGE_VERTICAL_COUNT (long)([UIScreen mainScreen].bounds.size.height * 1.0/BARRAGE_VERTICAL_HEIGHT) //垂直方向上的弹幕最大数量 | |
| 13 | -#define BARRAGE_VERTICAL_MARGIN ([UIScreen mainScreen].bounds.size.height - BARRAGE_VERTICAL_HEIGHT * MAX_BARRAGE_VERTICAL_COUNT) * 1.0 / (MAX_BARRAGE_VERTICAL_COUNT - 1) //垂直方向上弹幕之间的间隙 | |
| 14 | - | |
| 15 | -typedef NS_ENUM(NSInteger, CommentMoveState){//弹幕移动的状态 | |
| 16 | - CommentMoveStateStart = 0,//将要进入屏幕 | |
| 17 | - CommentMoveStateEnter ,//完全进入 | |
| 18 | - CommentMoveStateEnd //完全移除屏幕 | |
| 19 | -}; | |
| 20 | - | |
| 21 | - | |
| 22 | -@interface CNBarrageView : UIView | |
| 23 | - | |
| 24 | -@property (nonatomic ,copy) void (^moveBlock) (CommentMoveState state);//弹幕移动的状态 | |
| 25 | -@property (nonatomic) CGFloat trajectory;//弹幕的移动轨迹 | |
| 26 | - | |
| 27 | -/** | |
| 28 | - 初始化弹幕View根据评论内容,消息是否是自己发送 | |
| 29 | - | |
| 30 | - @param content 评论内容 | |
| 31 | - @param userName 用户名字 | |
| 32 | - @param isMine 是否是自己的评论弹幕 | |
| 33 | - @return 弹幕View | |
| 34 | - */ | |
| 35 | -- (instancetype)initWithContent:(NSString *)content userName:(NSString *)userName isMine:(BOOL)isMine; | |
| 36 | - | |
| 37 | -/** | |
| 38 | - 开始移动动画 | |
| 39 | - */ | |
| 40 | -- (void)startAnimation; | |
| 41 | - | |
| 42 | -/** | |
| 43 | - 停止移动动画 | |
| 44 | - */ | |
| 45 | -- (void)stopAnimation; | |
| 46 | - | |
| 47 | -@end |
LiveVideoCloud/LiveVideoCloud/Classes/Sections/InteractionSections/Chat/Barrage/CNBarrageView.m deleted
100644 → 0
| 1 | - | |
| 2 | -// | |
| 3 | -// CNBarrageView.m | |
| 4 | -// personalXmppChatDemo | |
| 5 | -// | |
| 6 | -// Created by 张旭 on 2016/12/10. | |
| 7 | -// Copyright © 2016年 cnlive. All rights reserved. | |
| 8 | -// | |
| 9 | - | |
| 10 | -#import "CNBarrageView.h" | |
| 11 | - | |
| 12 | -#define TotalDuration 5 //弹幕飘过总时间 | |
| 13 | -#define BARRAGE_Horizontal_Margin 5 //弹幕间水平间隙 | |
| 14 | - | |
| 15 | -@interface CNBarrageView () | |
| 16 | - | |
| 17 | -@property (nonatomic ,strong) UILabel * _Nullable commentLabel;//评论Label | |
| 18 | -@property BOOL isDealloc;//标记资源是否已释放 | |
| 19 | - | |
| 20 | -@end | |
| 21 | - | |
| 22 | -@implementation CNBarrageView | |
| 23 | - | |
| 24 | -/** | |
| 25 | - 销毁对象及动画 | |
| 26 | - */ | |
| 27 | -- (void)dealloc | |
| 28 | -{ | |
| 29 | - [self stopAnimation]; | |
| 30 | - self.moveBlock = nil; | |
| 31 | -} | |
| 32 | - | |
| 33 | -/** | |
| 34 | - 初始化弹幕View根据评论内容,消息是否是自己发送 | |
| 35 | - | |
| 36 | - @param content 评论内容 | |
| 37 | - @param userName 用户名字 | |
| 38 | - @param isMine 是否是自己的评论弹幕 | |
| 39 | - @return 弹幕View | |
| 40 | - */ | |
| 41 | -- (instancetype)initWithContent:(NSString *)content userName:(NSString *)userName isMine:(BOOL)isMine | |
| 42 | -{ | |
| 43 | - if (self = [super init]) | |
| 44 | - { | |
| 45 | - content = [NSString stringWithFormat:@"%@:%@",userName,content]; | |
| 46 | - NSDictionary *attributes = @{NSFontAttributeName:[UIFont systemFontOfSize:14]}; | |
| 47 | - float width = [content sizeWithAttributes:attributes].width; | |
| 48 | -// float height = [content sizeWithAttributes:attributes].height;//16.707031 | |
| 49 | - self.bounds = CGRectMake(0, 0, width + BARRAGE_Horizontal_Margin * 2, BARRAGE_VERTICAL_HEIGHT); | |
| 50 | - self.commentLabel.text = content; | |
| 51 | - self.commentLabel.frame = CGRectMake(BARRAGE_Horizontal_Margin, 0, width, BARRAGE_VERTICAL_HEIGHT); | |
| 52 | - if(isMine) | |
| 53 | - { | |
| 54 | - self.commentLabel.textColor = [UIColor redColor]; | |
| 55 | - }else | |
| 56 | - { | |
| 57 | - self.commentLabel.textColor = [UIColor lightGrayColor]; | |
| 58 | - } | |
| 59 | - | |
| 60 | - } | |
| 61 | - return self; | |
| 62 | -} | |
| 63 | - | |
| 64 | -/** | |
| 65 | - 开始移动动画 | |
| 66 | - */ | |
| 67 | -- (void)startAnimation | |
| 68 | -{ | |
| 69 | - CGFloat wholeWidth = self.width + SCREEN_WIDTH + 50;//总轨迹长度 | |
| 70 | - CGFloat speed = wholeWidth / TotalDuration;//速度 | |
| 71 | - CGFloat duration = (self.width + 50) / speed;//完全进入屏幕的时间 | |
| 72 | - | |
| 73 | - if (self.moveBlock) { | |
| 74 | - //弹幕开始进入屏幕 | |
| 75 | - self.moveBlock(CommentMoveStateStart); | |
| 76 | - } | |
| 77 | - | |
| 78 | - dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(duration * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{ | |
| 79 | - //避免重复,若资源已释放 不再操作 | |
| 80 | - if (self.isDealloc) { | |
| 81 | - return; | |
| 82 | - } | |
| 83 | - //duration时间后弹幕完全进入屏幕 | |
| 84 | - if (self.moveBlock) { | |
| 85 | - self.moveBlock(CommentMoveStateEnter); | |
| 86 | - } | |
| 87 | - }); | |
| 88 | - | |
| 89 | - weakself | |
| 90 | - //弹幕完全离开屏幕 | |
| 91 | - [UIView animateWithDuration:TotalDuration delay:0 options:UIViewAnimationOptionCurveLinear animations:^{ | |
| 92 | - strongself | |
| 93 | - self.left = - self.width; | |
| 94 | - } completion:^(BOOL finished) { | |
| 95 | - if (self.moveBlock) { | |
| 96 | - self.moveBlock(CommentMoveStateEnd); | |
| 97 | - } | |
| 98 | - [self removeFromSuperview]; | |
| 99 | - }]; | |
| 100 | - | |
| 101 | -} | |
| 102 | - | |
| 103 | -/** | |
| 104 | - 停止移动动画 | |
| 105 | - */ | |
| 106 | -- (void)stopAnimation | |
| 107 | -{ | |
| 108 | - self.isDealloc = YES; | |
| 109 | - [self.layer removeAllAnimations]; | |
| 110 | - [self removeFromSuperview]; | |
| 111 | -} | |
| 112 | - | |
| 113 | -#pragma mark getter | |
| 114 | - | |
| 115 | -- (UILabel *)commentLabel | |
| 116 | -{ | |
| 117 | - if (!_commentLabel) { | |
| 118 | - _commentLabel = [[UILabel alloc] init]; | |
| 119 | - _commentLabel.backgroundColor = [UIColor clearColor]; | |
| 120 | - _commentLabel.font = [UIFont systemFontOfSize:14.f]; | |
| 121 | - _commentLabel.textColor = [UIColor lightGrayColor]; | |
| 122 | - [self addSubview:self.commentLabel]; | |
| 123 | - } | |
| 124 | - return _commentLabel; | |
| 125 | -} | |
| 126 | - | |
| 127 | -/* | |
| 128 | -// Only override drawRect: if you perform custom drawing. | |
| 129 | -// An empty implementation adversely affects performance during animation. | |
| 130 | -- (void)drawRect:(CGRect)rect { | |
| 131 | - // Drawing code | |
| 132 | -} | |
| 133 | -*/ | |
| 134 | - | |
| 135 | -@end |
LiveVideoCloud/LiveVideoCloud/Classes/Sections/InteractionSections/Chat/BarrageManager/BarrageManager.h
0 → 100644
| 1 | +// | |
| 2 | +// BarrageManager.h | |
| 3 | +// LiveVideoCloud | |
| 4 | +// | |
| 5 | +// Created by 张旭 on 2017/3/24. | |
| 6 | +// Copyright © 2017年 cnlive. All rights reserved. | |
| 7 | +// | |
| 8 | + | |
| 9 | +#import <Foundation/Foundation.h> | |
| 10 | +@class chatMsgModel; | |
| 11 | +@class ChatBarrageView; | |
| 12 | +#import "AnimationBaseView.h" | |
| 13 | +@interface BarrageManager : NSObject <TouchPointDelegate> | |
| 14 | + | |
| 15 | +/** | |
| 16 | + 初始化管理类 | |
| 17 | + @return 当前manager | |
| 18 | + */ | |
| 19 | ++ (instancetype)sharedManager; | |
| 20 | + | |
| 21 | +- (ChatBarrageView *)addAnimationWithModel:(chatMsgModel *)model animContentView:(UIView *)animContentView; | |
| 22 | + | |
| 23 | +@end | ... | ... |
LiveVideoCloud/LiveVideoCloud/Classes/Sections/InteractionSections/Chat/BarrageManager/BarrageManager.m
0 → 100644
| 1 | +// | |
| 2 | +// BarrageManager.m | |
| 3 | +// LiveVideoCloud | |
| 4 | +// | |
| 5 | +// Created by 张旭 on 2017/3/24. | |
| 6 | +// Copyright © 2017年 cnlive. All rights reserved. | |
| 7 | +// | |
| 8 | + | |
| 9 | +#import "BarrageManager.h" | |
| 10 | +#import "chatMsgModel.h" | |
| 11 | +#import "ChatBarrageView.h" | |
| 12 | + | |
| 13 | +@interface BarrageManager ()<CAAnimationDelegate> | |
| 14 | + | |
| 15 | +@property (nonatomic ,strong) NSTimer * _Nullable timer; | |
| 16 | +@property (nonatomic ,strong) ChatBarrageView *_Nullable barrageView; | |
| 17 | +@property (nonatomic ,strong) AnimationBaseView * _Nullable animBaseView; | |
| 18 | +@property (nonatomic ,assign) CGRect barrCurrentRect; | |
| 19 | + | |
| 20 | +@end | |
| 21 | +@implementation BarrageManager | |
| 22 | + | |
| 23 | +/** | |
| 24 | + 初始化管理类 | |
| 25 | + @return 当前manager | |
| 26 | + */ | |
| 27 | ++ (instancetype)sharedManager{ | |
| 28 | + | |
| 29 | + static BarrageManager *manager; | |
| 30 | + | |
| 31 | + static dispatch_once_t onceToken; | |
| 32 | + dispatch_once(&onceToken, ^{ | |
| 33 | + manager = [[BarrageManager alloc] init]; | |
| 34 | + }); | |
| 35 | + return manager; | |
| 36 | +} | |
| 37 | + | |
| 38 | +//- (AnimationBaseView *)animBaseView | |
| 39 | +//{ | |
| 40 | +// if (!_animBaseView) | |
| 41 | +// { | |
| 42 | +// _animBaseView = [[AnimationBaseView alloc] init]; | |
| 43 | +// } | |
| 44 | +// return _animBaseView; | |
| 45 | +//} | |
| 46 | + | |
| 47 | +/** | |
| 48 | + 根据实际model添加动画 | |
| 49 | + | |
| 50 | + @param model modelobj | |
| 51 | + */ | |
| 52 | +- (ChatBarrageView *)addAnimationWithModel:(chatMsgModel *)model animContentView:(UIView *)animContentView | |
| 53 | +{ | |
| 54 | + ChatBarrageView *barrageView = [ChatBarrageView barrageViewWithPoint:CGPointMake(SCREEN_WIDTH + 50, 100)]; | |
| 55 | + barrageView.backgroundColor = [UIColor blackColor]; | |
| 56 | + [animContentView addSubview:barrageView]; | |
| 57 | + self.barrageView = barrageView; | |
| 58 | + self.animBaseView = (AnimationBaseView *)animContentView; | |
| 59 | + | |
| 60 | + barrageView.model = model; | |
| 61 | + | |
| 62 | + [self animationWithDuration:8 | |
| 63 | + YValues:@[ @(SCREEN_WIDTH + 50), @(-(200))] | |
| 64 | + keyTimes:@[@0.0, @1.0] | |
| 65 | + timingFunctions:@[ | |
| 66 | + [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionLinear], | |
| 67 | + ] | |
| 68 | + addView:barrageView]; | |
| 69 | + [self createTimer]; | |
| 70 | + self.animBaseView.isBarrage = YES; | |
| 71 | + | |
| 72 | +// [UIView animateWithDuration:10 animations:^{ | |
| 73 | +// | |
| 74 | +// barrageView.left = - 200; | |
| 75 | +// } completion:^(BOOL finished) { | |
| 76 | +// [self stopTimer]; | |
| 77 | +// [barrageView removeFromSuperview]; | |
| 78 | +// NSLog(@"finished"); | |
| 79 | +// }]; | |
| 80 | + return barrageView; | |
| 81 | +} | |
| 82 | + | |
| 83 | +// 实时监测 ,也可以用循环定时器 | |
| 84 | +- (void)createTimer{ | |
| 85 | + if (!self.timer) { | |
| 86 | + self.timer = [NSTimer scheduledTimerWithTimeInterval:0.1 target:self selector:@selector(jianCe) userInfo:nil repeats:YES]; | |
| 87 | + } | |
| 88 | +} | |
| 89 | +- (void) jianCe{ | |
| 90 | + CGRect rect = [[self.barrageView.layer presentationLayer ]frame]; // view指动画中移动的view | |
| 91 | + self.barrCurrentRect = rect; | |
| 92 | +// NSLog(@"箭%@",NSStringFromCGRect(rect)); | |
| 93 | +} | |
| 94 | + | |
| 95 | +- (void)stopTimer | |
| 96 | +{ | |
| 97 | + if(self.timer) | |
| 98 | + { | |
| 99 | + [self.timer invalidate]; | |
| 100 | + self.timer = nil; | |
| 101 | + } | |
| 102 | +} | |
| 103 | + | |
| 104 | +#pragma mark - touchPointDelegate | |
| 105 | +- (void)touchPoint:(CGPoint)touchPoint | |
| 106 | +{ | |
| 107 | + CGFloat dxLeft = touchPoint.x - self.barrCurrentRect.origin.x;// >0 | |
| 108 | + CGFloat dxRight = touchPoint.x - self.barrCurrentRect.origin.x - self.barrCurrentRect.size.width;// < 0 | |
| 109 | + CGFloat dyLeft = touchPoint.y - self.barrCurrentRect.origin.y;// >0 | |
| 110 | + CGFloat dyRight = touchPoint.y - self.barrCurrentRect.origin.y - self.barrCurrentRect.size.height;// <0 | |
| 111 | + | |
| 112 | + if (dxLeft > 0 && dxRight < 0 && dyLeft > 0 && dyRight < 0) { | |
| 113 | + //在当前矩形区域内 | |
| 114 | +// NSLog(@"在当前矩形区域内"); | |
| 115 | + [self.barrageView barrageViewClickWithModel:self.barrageView.model]; | |
| 116 | + }else | |
| 117 | + { | |
| 118 | +// NSLog(@"不在当前矩形区域内"); | |
| 119 | + } | |
| 120 | +} | |
| 121 | + | |
| 122 | +- (void)animationWithDuration:(float)duration YValues:(NSArray *)YValues keyTimes:(NSArray *)keyTimes timingFunctions:(NSArray *)timingFunctions addView:(UIView *)addView{ | |
| 123 | + CAKeyframeAnimation *rocketAnim = [CAKeyframeAnimation animation]; | |
| 124 | + rocketAnim.keyPath = @"position.x"; | |
| 125 | + rocketAnim.values = YValues; | |
| 126 | + rocketAnim.keyTimes = keyTimes; | |
| 127 | + rocketAnim.timingFunctions = timingFunctions; | |
| 128 | + rocketAnim.duration = duration; | |
| 129 | + rocketAnim.fillMode = kCAFillModeForwards; | |
| 130 | + rocketAnim.removedOnCompletion = NO; | |
| 131 | + rocketAnim.delegate = self; | |
| 132 | + [addView.layer addAnimation:rocketAnim forKey:@"positionY"]; | |
| 133 | +} | |
| 134 | + | |
| 135 | +- (void)animationDidStop:(CAAnimation *)anim finished:(BOOL)flag{ | |
| 136 | + NSLog(@"didStop"); | |
| 137 | + [self stopTimer]; | |
| 138 | + [self.barrageView removeFromSuperview]; | |
| 139 | + self.animBaseView.isBarrage = NO; | |
| 140 | +} | |
| 141 | +@end | ... | ... |
LiveVideoCloud/LiveVideoCloud/Classes/Sections/InteractionSections/Chat/ChatBarrageManager/ChatBarrOperation.h
0 → 100644
| 1 | +// | |
| 2 | +// ChatBarrOperation.h | |
| 3 | +// LiveVideoCloud | |
| 4 | +// | |
| 5 | +// Created by 张旭 on 2017/3/22. | |
| 6 | +// Copyright © 2017年 cnlive. All rights reserved. | |
| 7 | +// | |
| 8 | + | |
| 9 | +#import <Foundation/Foundation.h> | |
| 10 | + | |
| 11 | +@class chatMsgModel; | |
| 12 | + | |
| 13 | +/** | |
| 14 | + 动画完成回调 | |
| 15 | + */ | |
| 16 | +typedef void(^barrAnimationCompletion)(); | |
| 17 | + | |
| 18 | +/** | |
| 19 | + 可以开始动画回调 | |
| 20 | + */ | |
| 21 | +typedef void(^canAnimCompletion)(NSDictionary *); | |
| 22 | + | |
| 23 | +@protocol canAnimDelegate <NSObject> | |
| 24 | + | |
| 25 | +- (void)canAniCompletion; | |
| 26 | + | |
| 27 | +@end | |
| 28 | + | |
| 29 | +@interface ChatBarrOperation : NSOperation | |
| 30 | +{ | |
| 31 | + barrAnimationCompletion _completion; | |
| 32 | +} | |
| 33 | + | |
| 34 | +@property (nonatomic ,strong) id <canAnimDelegate> delegate; | |
| 35 | + | |
| 36 | ++ (instancetype)addAnimOperationWithModel:(chatMsgModel *)model animContentView:(UIView *)animContentView; | |
| 37 | + | |
| 38 | +@end | ... | ... |
LiveVideoCloud/LiveVideoCloud/Classes/Sections/InteractionSections/Chat/ChatBarrageManager/ChatBarrOperation.m
0 → 100644
| 1 | +// | |
| 2 | +// ChatBarrOperation.m | |
| 3 | +// LiveVideoCloud | |
| 4 | +// | |
| 5 | +// Created by 张旭 on 2017/3/22. | |
| 6 | +// Copyright © 2017年 cnlive. All rights reserved. | |
| 7 | +// | |
| 8 | + | |
| 9 | +#import "ChatBarrOperation.h" | |
| 10 | +#import "chatMsgModel.h" | |
| 11 | +#import "ChatBarrageView.h" | |
| 12 | + | |
| 13 | +@interface ChatBarrOperation ()<CAAnimationDelegate> | |
| 14 | +{ | |
| 15 | + BOOL _finished; //用于设置队列是否完成 | |
| 16 | + BOOL _executing; //队列任务开始执行 | |
| 17 | +} | |
| 18 | +@property (nonatomic ,strong) chatMsgModel * model;//model | |
| 19 | +@property (nonatomic ,strong) UIView * animContentView;//需要显示动画的view | |
| 20 | +@property (nonatomic ,strong) ChatBarrageView * _Nullable barrageView; | |
| 21 | +@property (nonatomic ,strong) NSArray * _Nullable defaultTrajory; | |
| 22 | +//@property (nonatomic ,strong) NSMutableDictionary * _Nullable trajoryStateDic; | |
| 23 | + | |
| 24 | +@end | |
| 25 | + | |
| 26 | +@implementation ChatBarrOperation | |
| 27 | + | |
| 28 | ++ (instancetype)addAnimOperationWithModel:(chatMsgModel *)model animContentView:(UIView *)animContentView | |
| 29 | +{ | |
| 30 | + ChatBarrOperation *barrAnimOperation = [[ChatBarrOperation alloc]initWithModel:model animContentView:animContentView]; | |
| 31 | + return barrAnimOperation; | |
| 32 | +} | |
| 33 | + | |
| 34 | +/** | |
| 35 | + 初始化 | |
| 36 | + | |
| 37 | + @param model 礼物model | |
| 38 | + @param animContentView 需要把动画view添加到的view | |
| 39 | + @return obj | |
| 40 | + */ | |
| 41 | +- (instancetype)initWithModel:(chatMsgModel *)model animContentView:(UIView *)animContentView{ | |
| 42 | + self = [super init]; | |
| 43 | + if (self) { | |
| 44 | + self.model = model; | |
| 45 | + self.animContentView = animContentView; | |
| 46 | + } | |
| 47 | + return self; | |
| 48 | +} | |
| 49 | + | |
| 50 | +/** | |
| 51 | + 开始方法(KVO控制队列任务状态) | |
| 52 | + */ | |
| 53 | +- (void)start{ | |
| 54 | +// NSLog(@"start"); | |
| 55 | + //这里动画队列任务不存在Cancelled状态所以不需要判断,直接开始执行 | |
| 56 | + [self willChangeValueForKey:@"isExecuting"]; | |
| 57 | + _executing = YES; | |
| 58 | + [self main]; | |
| 59 | + [self didChangeValueForKey:@"isExecuting"]; | |
| 60 | +} | |
| 61 | + | |
| 62 | +/** | |
| 63 | + 自定义Operation提供了start main接口。 | |
| 64 | + */ | |
| 65 | +- (void)main{ | |
| 66 | + [self barrageAnimation]; | |
| 67 | +} | |
| 68 | + | |
| 69 | +/** | |
| 70 | + 弹幕View | |
| 71 | + | |
| 72 | + @return 弹幕view | |
| 73 | + */ | |
| 74 | +- (ChatBarrageView *)barrageView{ | |
| 75 | + if (!_barrageView) { | |
| 76 | + _barrageView = [ChatBarrageView barrageViewWithPoint:CGPointMake(SCREEN_WIDTH + 50, 100)]; | |
| 77 | + _barrageView.animBaseView = (AnimationBaseView *)self.animContentView; | |
| 78 | + } | |
| 79 | + return _barrageView; | |
| 80 | +} | |
| 81 | + | |
| 82 | +static long currentCompleteIndex = 0; | |
| 83 | + | |
| 84 | +- (void)barrageAnimation | |
| 85 | +{ | |
| 86 | + weakself | |
| 87 | + dispatch_async(dispatch_get_main_queue(), ^{ | |
| 88 | + strongself | |
| 89 | + | |
| 90 | +// //获取空的最小轨道 | |
| 91 | +// int minIndex = -1;//默认没有 | |
| 92 | +// for (int i = 0 ; i < 3; i ++) { | |
| 93 | +// int state = [[self.trajoryStateDic objectForKey:[NSString stringWithFormat:@"state%d",i]] intValue]; | |
| 94 | +// NSLog(@"state%d,i%d",state,i); | |
| 95 | +// if (state == -1) {//null | |
| 96 | +// minIndex = i; | |
| 97 | +// break; | |
| 98 | +// } | |
| 99 | +// } | |
| 100 | +// if (minIndex == -1) {//没有空轨道 | |
| 101 | +// //等待有complete的op再继续执行 | |
| 102 | +// NSLog(@"等待complete"); | |
| 103 | +// | |
| 104 | +// }else//有最小空轨道 | |
| 105 | +// { | |
| 106 | +// NSLog(@"有最小空轨道"); | |
| 107 | + //初始化弹幕View | |
| 108 | +// self.barrageView = [ChatBarrageView barrageView]; | |
| 109 | + self.barrageView.model = self.model; | |
| 110 | + | |
| 111 | + NSLog(@"barrage:%@",self.barrageView); | |
| 112 | + [self.animContentView addSubview:self.barrageView]; | |
| 113 | + | |
| 114 | + self.barrageView.top = [self.defaultTrajory[currentCompleteIndex] integerValue]; | |
| 115 | + currentCompleteIndex ++; | |
| 116 | + if (currentCompleteIndex == 3) | |
| 117 | + { | |
| 118 | + currentCompleteIndex = 0; | |
| 119 | + } | |
| 120 | + | |
| 121 | +// NSString *key = [NSString stringWithFormat:@"state%d",minIndex]; | |
| 122 | +// [self.trajoryStateDic setValue:@1 forKey:key]; | |
| 123 | +// [self.trajoryStateDic setValue:self.name forKey:[NSString stringWithFormat:@"name%d",minIndex]]; | |
| 124 | +// NSLog(@"top:%zd,index%d",[self.defaultTrajory[currentCompleteIndex] integerValue],minIndex); | |
| 125 | + [self.barrageView startBarrageAnimationWithCompletion:^{ | |
| 126 | + | |
| 127 | + NSLog(@"completion"); | |
| 128 | +// [self.trajoryStateDic setValue:@(-1) forKey:[NSString stringWithFormat:@"state%d",minIndex]]; | |
| 129 | +// [self.trajoryStateDic setValue:@"" forKey:[NSString stringWithFormat:@"name%d",minIndex]]; | |
| 130 | + if ([self.delegate respondsToSelector:@selector(canAniCompletion)]) { | |
| 131 | + [self.delegate canAniCompletion]; | |
| 132 | + } | |
| 133 | + [self willChangeValueForKey:@"isFinished"]; | |
| 134 | + | |
| 135 | + _finished = YES; | |
| 136 | + | |
| 137 | + [self didChangeValueForKey:@"isFinished"]; | |
| 138 | + }]; | |
| 139 | +// } | |
| 140 | + | |
| 141 | + }); | |
| 142 | +} | |
| 143 | + | |
| 144 | +- (NSArray *)defaultTrajory | |
| 145 | +{ | |
| 146 | + if (!_defaultTrajory) | |
| 147 | + { | |
| 148 | + _defaultTrajory = [[NSArray alloc] initWithObjects:@200,@240,@280, nil]; | |
| 149 | + } | |
| 150 | + return _defaultTrajory; | |
| 151 | +} | |
| 152 | + | |
| 153 | +//- (NSMutableDictionary *)trajoryStateDic | |
| 154 | +//{ | |
| 155 | +// if (!_trajoryStateDic) | |
| 156 | +// { | |
| 157 | +// _trajoryStateDic = [NSMutableDictionary dictionaryWithObjectsAndKeys:@(-1),@"state0",@(-1),@"state1",@(-1),@"state2",@"",@"name0",@"",@"name1",@"",@"name2", nil]; | |
| 158 | +// } | |
| 159 | +// return _trajoryStateDic; | |
| 160 | +//} | |
| 161 | + | |
| 162 | +// 提示:To be deprecated; use and override 'asynchronous' below | |
| 163 | +//之前用的isConcurrent | |
| 164 | +/** | |
| 165 | + 覆写异步执行 | |
| 166 | + | |
| 167 | + @return YES | |
| 168 | + */ | |
| 169 | +- (BOOL)isAsynchronous{ | |
| 170 | +// NSLog(@"isAsynchronous"); | |
| 171 | + return YES; | |
| 172 | +} | |
| 173 | + | |
| 174 | +/** | |
| 175 | + 覆写任务是否完成控制 | |
| 176 | + | |
| 177 | + @return 完成状态 _finished | |
| 178 | + */ | |
| 179 | +- (BOOL) isFinished{ | |
| 180 | +// NSLog(@"isFinished%d",_finished); | |
| 181 | + return _finished; | |
| 182 | +} | |
| 183 | + | |
| 184 | +/** | |
| 185 | + 覆写任务是否完成开始执行 | |
| 186 | + | |
| 187 | + @return 执行状态 _executing | |
| 188 | + */ | |
| 189 | +- (BOOL) isExecuting{ | |
| 190 | +// NSLog(@"isExecuting%d",_executing); | |
| 191 | + return _executing; | |
| 192 | +} | |
| 193 | +@end | ... | ... |
LiveVideoCloud/LiveVideoCloud/Classes/Sections/InteractionSections/Chat/ChatBarrageManager/ChatBarrageAnimAction.h
0 → 100644
| 1 | +// | |
| 2 | +// ChatBarrageAnimAction.h | |
| 3 | +// LiveVideoCloud | |
| 4 | +// | |
| 5 | +// Created by 张旭 on 2017/3/22. | |
| 6 | +// Copyright © 2017年 cnlive. All rights reserved. | |
| 7 | +// | |
| 8 | + | |
| 9 | +#import <UIKit/UIKit.h> | |
| 10 | +/** | |
| 11 | + 动画完成回调 | |
| 12 | + */ | |
| 13 | +typedef void(^barrAnimationCompletion)(); | |
| 14 | + | |
| 15 | +@interface ChatBarrageAnimAction : UIView<CAAnimationDelegate>{ | |
| 16 | + barrAnimationCompletion _barrAnimationCompletion; //动画完成回调 | |
| 17 | +} | |
| 18 | + | |
| 19 | +/** | |
| 20 | + 弹幕动画 | |
| 21 | + */ | |
| 22 | +- (void)startBarrageAnimationWithCompletion:(barrAnimationCompletion)completion; | |
| 23 | + | |
| 24 | +@end | ... | ... |
LiveVideoCloud/LiveVideoCloud/Classes/Sections/InteractionSections/Chat/ChatBarrageManager/ChatBarrageAnimAction.m
0 → 100644
| 1 | +// | |
| 2 | +// ChatBarrageAnimAction.m | |
| 3 | +// LiveVideoCloud | |
| 4 | +// | |
| 5 | +// Created by 张旭 on 2017/3/22. | |
| 6 | +// Copyright © 2017年 cnlive. All rights reserved. | |
| 7 | +// | |
| 8 | + | |
| 9 | +#import "ChatBarrageAnimAction.h" | |
| 10 | + | |
| 11 | +@interface ChatBarrageAnimAction ()<CAAnimationDelegate> | |
| 12 | + | |
| 13 | + | |
| 14 | +@end | |
| 15 | + | |
| 16 | +@implementation ChatBarrageAnimAction | |
| 17 | + | |
| 18 | +/** | |
| 19 | + 弹幕动画 | |
| 20 | + */ | |
| 21 | +- (void)startBarrageAnimationWithCompletion:(barrAnimationCompletion)completion; | |
| 22 | +{ | |
| 23 | + _barrAnimationCompletion = completion; | |
| 24 | +// self.left = SCREEN_WIDTH + 50; | |
| 25 | +// NSLog(@"frame:%@",NSStringFromCGRect(self.frame)); | |
| 26 | +// [UIView animateWithDuration:10 animations:^{ | |
| 27 | +// self.left = - 200; | |
| 28 | +// | |
| 29 | +// } completion:^(BOOL finished) { | |
| 30 | +// _barrAnimationCompletion(); | |
| 31 | +// }]; | |
| 32 | + [self animationWithDuration:8 | |
| 33 | + YValues:@[ @(SCREEN_WIDTH + 50), @(-(200))] | |
| 34 | + keyTimes:@[@0.0, @1.0] | |
| 35 | + timingFunctions:@[ | |
| 36 | + [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionLinear], | |
| 37 | + ] | |
| 38 | + addView:self]; | |
| 39 | +} | |
| 40 | + | |
| 41 | +/** | |
| 42 | + 位移动画具体实现 | |
| 43 | + | |
| 44 | + @param duration 动画持续时间 | |
| 45 | + @param YValues 动画帧数组 | |
| 46 | + @param keyTimes 动画帧时间 | |
| 47 | + @param timingFunctions 动画方式数组 | |
| 48 | + @param addView 需要添加的view | |
| 49 | + */ | |
| 50 | +- (void)animationWithDuration:(float)duration YValues:(NSArray *)YValues keyTimes:(NSArray *)keyTimes timingFunctions:(NSArray *)timingFunctions addView:(UIView *)addView{ | |
| 51 | + CAKeyframeAnimation *rocketAnim = [CAKeyframeAnimation animation]; | |
| 52 | + rocketAnim.keyPath = @"position.x"; | |
| 53 | + rocketAnim.values = YValues; | |
| 54 | + rocketAnim.keyTimes = keyTimes; | |
| 55 | + rocketAnim.timingFunctions = timingFunctions; | |
| 56 | + rocketAnim.duration = duration; | |
| 57 | + rocketAnim.fillMode = kCAFillModeForwards; | |
| 58 | + rocketAnim.removedOnCompletion = NO; | |
| 59 | + rocketAnim.delegate = self; | |
| 60 | + [addView.layer addAnimation:rocketAnim forKey:@"positionY"]; | |
| 61 | +} | |
| 62 | + | |
| 63 | +/** | |
| 64 | + 动画回调代理,用于判断是否完成 | |
| 65 | + | |
| 66 | + @param anim 动画对象 | |
| 67 | + @param flag 是否完成标记 | |
| 68 | + */ | |
| 69 | +- (void)animationDidStop:(CAAnimation *)anim finished:(BOOL)flag{ | |
| 70 | + _barrAnimationCompletion(); | |
| 71 | +} | |
| 72 | + | |
| 73 | +/* | |
| 74 | +// Only override drawRect: if you perform custom drawing. | |
| 75 | +// An empty implementation adversely affects performance during animation. | |
| 76 | +- (void)drawRect:(CGRect)rect { | |
| 77 | + // Drawing code | |
| 78 | +} | |
| 79 | +*/ | |
| 80 | + | |
| 81 | +@end | ... | ... |
LiveVideoCloud/LiveVideoCloud/Classes/Sections/InteractionSections/Chat/ChatBarrageManager/ChatBarrageManager.h
0 → 100644
| 1 | +// | |
| 2 | +// ChatBarrageManager.h | |
| 3 | +// LiveVideoCloud | |
| 4 | +// | |
| 5 | +// Created by 张旭 on 2017/3/22. | |
| 6 | +// Copyright © 2017年 cnlive. All rights reserved. | |
| 7 | +// | |
| 8 | + | |
| 9 | +#import <Foundation/Foundation.h> | |
| 10 | + | |
| 11 | +@class chatMsgModel; | |
| 12 | + | |
| 13 | +@interface ChatBarrageManager : NSObject | |
| 14 | + | |
| 15 | +/** | |
| 16 | + 初始化管理类 | |
| 17 | + @return 当前manager | |
| 18 | + */ | |
| 19 | ++ (instancetype)sharedManager; | |
| 20 | + | |
| 21 | +- (void)addAnimationWithModel:(chatMsgModel *)model animContentView:(UIView *)animContentView; | |
| 22 | + | |
| 23 | +@end | ... | ... |
LiveVideoCloud/LiveVideoCloud/Classes/Sections/InteractionSections/Chat/ChatBarrageManager/ChatBarrageManager.m
0 → 100644
| 1 | +// | |
| 2 | +// ChatBarrageManager.m | |
| 3 | +// LiveVideoCloud | |
| 4 | +// | |
| 5 | +// Created by 张旭 on 2017/3/22. | |
| 6 | +// Copyright © 2017年 cnlive. All rights reserved. | |
| 7 | +// | |
| 8 | + | |
| 9 | +#import "ChatBarrageManager.h" | |
| 10 | +#import "chatMsgModel.h" | |
| 11 | +#import "ChatBarrOperation.h" | |
| 12 | + | |
| 13 | +@interface ChatBarrageManager ()<canAnimDelegate> | |
| 14 | + | |
| 15 | +@property (nonatomic,strong) NSOperationQueue *barrageAnimationQueue; //聊天弹幕动画队列 | |
| 16 | +@property (nonatomic ,strong) NSMutableArray * _Nullable tempOperationArr; | |
| 17 | + | |
| 18 | +@end | |
| 19 | + | |
| 20 | +@implementation ChatBarrageManager | |
| 21 | + | |
| 22 | +/** | |
| 23 | + 初始化管理类 | |
| 24 | + @return 当前manager | |
| 25 | + */ | |
| 26 | ++ (instancetype)sharedManager{ | |
| 27 | + | |
| 28 | + static ChatBarrageManager *manager; | |
| 29 | + | |
| 30 | + static dispatch_once_t onceToken; | |
| 31 | + dispatch_once(&onceToken, ^{ | |
| 32 | + manager = [[ChatBarrageManager alloc] init]; | |
| 33 | + }); | |
| 34 | + return manager; | |
| 35 | +} | |
| 36 | + | |
| 37 | +/** | |
| 38 | + 聊天弹幕动画队列 | |
| 39 | + | |
| 40 | + @return 队列obj | |
| 41 | + */ | |
| 42 | +- (NSOperationQueue *)barrageAnimationQueue{ | |
| 43 | + if (_barrageAnimationQueue == nil) { | |
| 44 | + _barrageAnimationQueue = [[NSOperationQueue alloc] init]; | |
| 45 | + _barrageAnimationQueue.maxConcurrentOperationCount = 1; | |
| 46 | + } | |
| 47 | + return _barrageAnimationQueue; | |
| 48 | +} | |
| 49 | + | |
| 50 | +- (NSMutableArray *)tempOperationArr | |
| 51 | +{ | |
| 52 | + if (!_tempOperationArr) | |
| 53 | + { | |
| 54 | + _tempOperationArr = [[NSMutableArray alloc] init]; | |
| 55 | + } | |
| 56 | + return _tempOperationArr; | |
| 57 | +} | |
| 58 | + | |
| 59 | +/** | |
| 60 | + 根据实际model添加动画 | |
| 61 | + | |
| 62 | + @param model modelobj | |
| 63 | + */ | |
| 64 | +- (void)addAnimationWithModel:(chatMsgModel *)model animContentView:(UIView *)animContentView{ | |
| 65 | + | |
| 66 | + ChatBarrOperation *op = [ChatBarrOperation addAnimOperationWithModel:model animContentView:animContentView]; | |
| 67 | + op.delegate = self; | |
| 68 | +// op.name = model.name;//换UID | |
| 69 | +// NSLog(@"opeCount:%zd",self.barrageAnimationQueue.operationCount); | |
| 70 | + if (self.barrageAnimationQueue.operationCount >= 3) { | |
| 71 | + [self.tempOperationArr addObject:op]; | |
| 72 | + }else | |
| 73 | + { | |
| 74 | + [self.barrageAnimationQueue addOperation:op]; | |
| 75 | + } | |
| 76 | +} | |
| 77 | + | |
| 78 | +- (void)canAniCompletion | |
| 79 | +{ | |
| 80 | + //将临时数组的op加到Queue中 | |
| 81 | + if (self.tempOperationArr.count > 0) { | |
| 82 | + [self.barrageAnimationQueue addOperation:[self.tempOperationArr firstObject]]; | |
| 83 | + [self.tempOperationArr removeObjectAtIndex:0]; | |
| 84 | + } | |
| 85 | +} | |
| 86 | + | |
| 87 | +@end | ... | ... |
LiveVideoCloud/LiveVideoCloud/Classes/Sections/InteractionSections/Chat/ChatBarrageManager/ChatBarrageView.h
0 → 100644
| 1 | +// | |
| 2 | +// ChatBarrageView.h | |
| 3 | +// LiveVideoCloud | |
| 4 | +// | |
| 5 | +// Created by 张旭 on 2017/3/22. | |
| 6 | +// Copyright © 2017年 cnlive. All rights reserved. | |
| 7 | +// | |
| 8 | + | |
| 9 | +#import "ChatBarrageAnimAction.h" | |
| 10 | + | |
| 11 | +@class AnimationBaseView; | |
| 12 | +@class chatMsgModel; | |
| 13 | +@interface ChatBarrageView : ChatBarrageAnimAction | |
| 14 | + | |
| 15 | +@property (nonatomic ,strong) chatMsgModel * _Nullable model; | |
| 16 | + | |
| 17 | ++ (instancetype _Nullable)barrageViewWithPoint:(CGPoint)point; | |
| 18 | + | |
| 19 | +- (void)barrageViewClickWithModel:(chatMsgModel *_Nullable)model; | |
| 20 | +@property (nonatomic ,strong) AnimationBaseView * _Nullable animBaseView; | |
| 21 | + | |
| 22 | +@end | ... | ... |
LiveVideoCloud/LiveVideoCloud/Classes/Sections/InteractionSections/Chat/ChatBarrageManager/ChatBarrageView.m
0 → 100644
| 1 | +// | |
| 2 | +// ChatBarrageView.m | |
| 3 | +// LiveVideoCloud | |
| 4 | +// | |
| 5 | +// Created by 张旭 on 2017/3/22. | |
| 6 | +// Copyright © 2017年 cnlive. All rights reserved. | |
| 7 | +// | |
| 8 | + | |
| 9 | +#import "ChatBarrageView.h" | |
| 10 | +#import "chatMsgModel.h" | |
| 11 | +#import "userInfoModel.h" | |
| 12 | +#import "AnimationBaseView.h" | |
| 13 | + | |
| 14 | +@interface ChatBarrageView ()<TouchPointDelegate> | |
| 15 | + | |
| 16 | +@property (nonatomic ,strong) UIImageView * _Nullable icon; | |
| 17 | +@property (nonatomic ,strong) UILabel * _Nullable nameLbl; | |
| 18 | +@property (nonatomic ,strong) UILabel * _Nullable contentLbl; | |
| 19 | + | |
| 20 | +@property (nonatomic ,strong) NSTimer * _Nullable timer; | |
| 21 | +@property (nonatomic ,assign) CGRect barrCurrentRect; | |
| 22 | +@end | |
| 23 | + | |
| 24 | +@implementation ChatBarrageView | |
| 25 | + | |
| 26 | ++ (instancetype _Nullable)barrageViewWithPoint:(CGPoint)point | |
| 27 | +{ | |
| 28 | + ChatBarrageView *barrageView = [[ChatBarrageView alloc] initWithFrame:CGRectMake(point.x, point.y, 200, 50)]; | |
| 29 | + return barrageView; | |
| 30 | +} | |
| 31 | + | |
| 32 | +- (instancetype)initWithFrame:(CGRect)frame | |
| 33 | +{ | |
| 34 | + if (self = [super initWithFrame:frame]) { | |
| 35 | + [self createTimer]; | |
| 36 | + | |
| 37 | + self.layer.cornerRadius = self.height * 0.5; | |
| 38 | + self.layer.masksToBounds = YES; | |
| 39 | + self.backgroundColor = [UIColor yellowColor]; | |
| 40 | + [self addSubview:self.contentLbl]; | |
| 41 | + } | |
| 42 | + return self; | |
| 43 | +} | |
| 44 | + | |
| 45 | +- (void)setAnimBaseView:(AnimationBaseView *)animBaseView | |
| 46 | +{ | |
| 47 | + _animBaseView = animBaseView; | |
| 48 | + self.animBaseView.isBarrage = YES; | |
| 49 | + self.animBaseView.delegate = self; | |
| 50 | +} | |
| 51 | + | |
| 52 | +// 实时监测 ,也可以用循环定时器 | |
| 53 | +- (void)createTimer{ | |
| 54 | + if (!self.timer) { | |
| 55 | + self.timer = [NSTimer scheduledTimerWithTimeInterval:0.1 target:self selector:@selector(jianCe) userInfo:nil repeats:YES]; | |
| 56 | + } | |
| 57 | +} | |
| 58 | +- (void) jianCe{ | |
| 59 | + CGRect rect = [[self.layer presentationLayer ]frame]; // view指动画中移动的view | |
| 60 | + self.barrCurrentRect = rect; | |
| 61 | + // NSLog(@"箭%@",NSStringFromCGRect(rect)); | |
| 62 | +} | |
| 63 | + | |
| 64 | +- (void)stopTimer | |
| 65 | +{ | |
| 66 | + if(self.timer) | |
| 67 | + { | |
| 68 | + [self.timer invalidate]; | |
| 69 | + self.timer = nil; | |
| 70 | + } | |
| 71 | +} | |
| 72 | + | |
| 73 | +#pragma mark - touchPointDelegate | |
| 74 | +- (void)touchPoint:(CGPoint)touchPoint | |
| 75 | +{ | |
| 76 | + CGFloat dxLeft = touchPoint.x - self.barrCurrentRect.origin.x;// >0 | |
| 77 | + CGFloat dxRight = touchPoint.x - self.barrCurrentRect.origin.x - self.barrCurrentRect.size.width;// < 0 | |
| 78 | + CGFloat dyLeft = touchPoint.y - self.barrCurrentRect.origin.y;// >0 | |
| 79 | + CGFloat dyRight = touchPoint.y - self.barrCurrentRect.origin.y - self.barrCurrentRect.size.height;// <0 | |
| 80 | + | |
| 81 | + if (dxLeft > 0 && dxRight < 0 && dyLeft > 0 && dyRight < 0) { | |
| 82 | + //在当前矩形区域内 | |
| 83 | + // NSLog(@"在当前矩形区域内"); | |
| 84 | + [self barrageViewClickWithModel:self.model]; | |
| 85 | + }else | |
| 86 | + { | |
| 87 | + // NSLog(@"不在当前矩形区域内"); | |
| 88 | + } | |
| 89 | +} | |
| 90 | + | |
| 91 | +- (void)animationDidStop:(CAAnimation *)anim finished:(BOOL)flag | |
| 92 | +{ | |
| 93 | + _barrAnimationCompletion(); | |
| 94 | + [self stopTimer]; | |
| 95 | + [self removeFromSuperview]; | |
| 96 | + self.animBaseView.isBarrage = NO; | |
| 97 | + | |
| 98 | +} | |
| 99 | + | |
| 100 | +- (void)barrageViewClickWithModel:(chatMsgModel *)model | |
| 101 | +{ | |
| 102 | + //展示个人详细页 | |
| 103 | + userInfoModel *userModel = [[userInfoModel alloc] init]; | |
| 104 | + userModel.icon = model.icon; | |
| 105 | + userModel.name = model.name; | |
| 106 | + userModel.sign = model.content;//@"我就是签名,不服来辩"; | |
| 107 | + userModel.uId = @"111222"; | |
| 108 | + [Tools showBouncedWithModel:userModel callBackBlock:^(UIView * _Nullable bounceView) { | |
| 109 | + | |
| 110 | + }]; | |
| 111 | +} | |
| 112 | + | |
| 113 | +- (void)setModel:(chatMsgModel *)model | |
| 114 | +{ | |
| 115 | + _model = model; | |
| 116 | + [self.icon zx_setHeader:model.icon]; | |
| 117 | + self.nameLbl.text = model.name; | |
| 118 | + self.contentLbl.text = model.content; | |
| 119 | +} | |
| 120 | + | |
| 121 | +- (UIImageView *)icon | |
| 122 | +{ | |
| 123 | + if (!_icon) | |
| 124 | + { | |
| 125 | + _icon = [[UIImageView alloc] initWithFrame:CGRectMake(10, 4, self.height -6, self.height -6)]; | |
| 126 | + _icon.centerY = self.height * 0.5; | |
| 127 | + [self addSubview:_icon]; | |
| 128 | + } | |
| 129 | + return _icon; | |
| 130 | +} | |
| 131 | + | |
| 132 | +- (UILabel *)nameLbl | |
| 133 | +{ | |
| 134 | + if (!_nameLbl) | |
| 135 | + { | |
| 136 | + _nameLbl = [[UILabel alloc] initWithFrame:CGRectMake(self.icon.right + 10, 0, self.width - self.icon.right - 10, self.height * 0.5)]; | |
| 137 | + _nameLbl.textAlignment = NSTextAlignmentLeft; | |
| 138 | + _nameLbl.textColor = ZXRandomColor; | |
| 139 | + _nameLbl.font = [UIFont systemFontOfSize:kContentFont]; | |
| 140 | + [self addSubview:_nameLbl]; | |
| 141 | + } | |
| 142 | + return _nameLbl; | |
| 143 | +} | |
| 144 | + | |
| 145 | +- (UILabel *)contentLbl | |
| 146 | +{ | |
| 147 | + if (!_contentLbl) | |
| 148 | + { | |
| 149 | + _contentLbl = [[UILabel alloc] initWithFrame:CGRectMake(self.nameLbl.left, self.nameLbl.bottom, self.nameLbl.width, self.height * 0.5)]; | |
| 150 | + _contentLbl.textAlignment = NSTextAlignmentLeft; | |
| 151 | + _contentLbl.textColor = ZXRandomColor; | |
| 152 | + _contentLbl.font = [UIFont systemFontOfSize:kContentFont]; | |
| 153 | + } | |
| 154 | + return _contentLbl; | |
| 155 | +} | |
| 156 | + | |
| 157 | +/* | |
| 158 | +// Only override drawRect: if you perform custom drawing. | |
| 159 | +// An empty implementation adversely affects performance during animation. | |
| 160 | +- (void)drawRect:(CGRect)rect { | |
| 161 | + // Drawing code | |
| 162 | +} | |
| 163 | +*/ | |
| 164 | + | |
| 165 | +@end | ... | ... |
LiveVideoCloud/LiveVideoCloud/Classes/Sections/InteractionSections/Chat/ChatMsgModel/chatMsgModel.m
LiveVideoCloud/LiveVideoCloud/Classes/Sections/InteractionSections/Gift/AnimQueueManager.h
LiveVideoCloud/LiveVideoCloud/Classes/Sections/InteractionSections/Gift/AnimQueueManager.m
LiveVideoCloud/LiveVideoCloud/Classes/Sections/InteractionSections/Gift/GiftAnimOperation.m
LiveVideoCloud/LiveVideoCloud/Classes/Sections/InteractionSections/LiveBaseView.h
| ... | ... | @@ -8,10 +8,10 @@ |
| 8 | 8 | |
| 9 | 9 | #import "BaseView.h" |
| 10 | 10 | @class PresentView; |
| 11 | - | |
| 11 | +@class AnimationBaseView; | |
| 12 | 12 | @interface LiveBaseView : BaseView |
| 13 | 13 | |
| 14 | 14 | @property (nonatomic ,strong) UIViewController * _Nullable viewController; |
| 15 | 15 | @property (nonatomic ,strong ,readonly) PresentView * _Nullable presentView; |
| 16 | -@property (nonatomic ,strong ,readonly) UIView * _Nullable animationBaseView; | |
| 16 | +@property (nonatomic ,strong ,readonly) AnimationBaseView * _Nullable animationBaseView; | |
| 17 | 17 | @end | ... | ... |
LiveVideoCloud/LiveVideoCloud/Classes/Sections/InteractionSections/LiveBaseView.m
| ... | ... | @@ -17,9 +17,18 @@ |
| 17 | 17 | #import "chatListCell.h" |
| 18 | 18 | #import "chatMsgModel.h" |
| 19 | 19 | #import "TopToolView.h" |
| 20 | +#import "ChatBarrageManager.h" | |
| 21 | +#import "userInfoModel.h" | |
| 22 | +#import "PrivateView.h" | |
| 23 | +//#import "BarrageManager.h" | |
| 24 | +#import "ChatBarrageView.h" | |
| 25 | +#import "AnimationBaseView.h" | |
| 20 | 26 | |
| 21 | 27 | #define BottomToolHeight 60 |
| 22 | 28 | |
| 29 | +static NSString *message_barrage = @"message_barrage"; | |
| 30 | +static NSString *message_content = @"message_content"; | |
| 31 | + | |
| 23 | 32 | typedef NS_ENUM(NSInteger, PopType) {//弹窗类型 |
| 24 | 33 | PopTypeGift = 1,//礼物弹窗 |
| 25 | 34 | PopTypeChat ,//聊天弹窗 |
| ... | ... | @@ -29,7 +38,7 @@ typedef NS_ENUM(NSInteger, PopType) {//弹窗类型 |
| 29 | 38 | @interface LiveBaseView ()<bottomBtnDeledate,PresentViewDelegate,UIScrollViewDelegate,UITableViewDelegate,UITableViewDataSource,UITextFieldDelegate,userClickDelegate,CNLiveChatManagerDelegate> |
| 30 | 39 | |
| 31 | 40 | @property (nonatomic ,strong ) UIScrollView * _Nullable scrollView; |
| 32 | -@property (nonatomic ,strong ,readwrite) UIView * _Nullable animationBaseView;//展示层View | |
| 41 | +@property (nonatomic ,strong ,readwrite) AnimationBaseView * _Nullable animationBaseView;//展示层View | |
| 33 | 42 | @property (nonatomic ,strong ) BottomToolView* _Nullable bottomToolView; |
| 34 | 43 | @property (nonatomic ,strong ) UIButton * _Nullable closeBtn; |
| 35 | 44 | @property (nonatomic ,strong ) GiftListView * _Nullable giftListView; |
| ... | ... | @@ -38,11 +47,15 @@ typedef NS_ENUM(NSInteger, PopType) {//弹窗类型 |
| 38 | 47 | @property (nonatomic ,assign ) PopType popType; |
| 39 | 48 | @property (nonatomic ,strong ) UITableView * _Nullable chatTableView; |
| 40 | 49 | @property (nonatomic ,strong ) NSMutableArray * _Nullable chatMsgArray;//聊天消息数组 |
| 41 | -@property (nonatomic ,strong ) TopToolView * _Nullable topToolsView; | |
| 42 | -@property (nonatomic ,strong ) UIView * _Nullable commentsView; | |
| 43 | -@property (nonatomic ,strong ) UITextField * _Nullable commentText; | |
| 50 | +@property (nonatomic ,strong ) TopToolView * _Nullable topToolsView; | |
| 51 | +@property (nonatomic ,strong ) UIView * _Nullable commentsView; | |
| 52 | +@property (nonatomic ,strong ) UITextField * _Nullable commentText; | |
| 44 | 53 | @property (nonatomic ,assign ) CGFloat offsetHeight; |
| 45 | -@property (nonatomic ,strong ) UISwitch * _Nullable barrageSwitch; | |
| 54 | +@property (nonatomic ,strong ) UISwitch * _Nullable barrageSwitch; | |
| 55 | +@property (nonatomic ,strong ) ChatBarrageManager * _Nullable chatManager; | |
| 56 | +//@property (nonatomic ,strong ) BarrageManager * _Nullable barrManager; | |
| 57 | + | |
| 58 | +@property (nonatomic ,strong) ChatBarrageView * _Nullable barrageView; | |
| 46 | 59 | |
| 47 | 60 | @end |
| 48 | 61 | |
| ... | ... | @@ -52,6 +65,7 @@ typedef NS_ENUM(NSInteger, PopType) {//弹窗类型 |
| 52 | 65 | { |
| 53 | 66 | if (self = [super initWithFrame:frame]) { |
| 54 | 67 | |
| 68 | + self.clipsToBounds = YES; | |
| 55 | 69 | [self addSubview:self.scrollView]; |
| 56 | 70 | [self.scrollView addSubview:self.animationBaseView]; |
| 57 | 71 | [self.animationBaseView addSubview:self.bottomToolView]; |
| ... | ... | @@ -69,7 +83,7 @@ typedef NS_ENUM(NSInteger, PopType) {//弹窗类型 |
| 69 | 83 | [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardWillHidden:) name:UIKeyboardWillHideNotification object:nil]; |
| 70 | 84 | |
| 71 | 85 | [CNLiveChatManager sharedCNLiveChatManager].delegate = self; |
| 72 | - [[CNLiveChatManager sharedCNLiveChatManager] joinChatRoom:@"123" messageCount:50 success:^(NSString *targetId) { | |
| 86 | + [[CNLiveChatManager sharedCNLiveChatManager] joinChatRoom:@"1234" messageCount:10 success:^(NSString *targetId) { | |
| 73 | 87 | NSLog(@"success"); |
| 74 | 88 | } error:^(CNLiveChatErrorCode errors, NSString *targetId) { |
| 75 | 89 | NSLog(@"error"); |
| ... | ... | @@ -111,12 +125,7 @@ typedef NS_ENUM(NSInteger, PopType) {//弹窗类型 |
| 111 | 125 | bgView.userInteractionEnabled = YES; |
| 112 | 126 | [_commentsView addSubview:bgView]; |
| 113 | 127 | |
| 114 | - _barrageSwitch = [[UISwitch alloc] initWithFrame:CGRectMake(10, 10, 40, 30)]; | |
| 115 | - _barrageSwitch.tintColor = [UIColor orangeColor]; | |
| 116 | - _barrageSwitch.onTintColor = [UIColor orangeColor]; | |
| 117 | - _barrageSwitch.thumbTintColor = [UIColor lightGrayColor]; | |
| 118 | - _barrageSwitch.centerY = _commentsView.height * 0.5; | |
| 119 | - [bgView addSubview:_barrageSwitch]; | |
| 128 | + [bgView addSubview:self.barrageSwitch]; | |
| 120 | 129 | |
| 121 | 130 | UIButton *sendBtn = [[UIButton alloc] initWithFrame:CGRectMake(_commentsView.width - 80, 0, 80, _commentsView.height)]; |
| 122 | 131 | [sendBtn addTarget:self action:@selector(sendClick) forControlEvents:UIControlEventTouchUpInside]; |
| ... | ... | @@ -134,9 +143,11 @@ typedef NS_ENUM(NSInteger, PopType) {//弹窗类型 |
| 134 | 143 | _commentText.returnKeyType = UIReturnKeySend; |
| 135 | 144 | _commentText.delegate = self; |
| 136 | 145 | _commentText.font = [UIFont systemFontOfSize:15.0]; |
| 146 | + _commentText.placeholder = @"和大家说点什么吧"; | |
| 137 | 147 | [bgView addSubview:_commentText]; |
| 138 | 148 | } |
| 139 | - [[[UIApplication sharedApplication]keyWindow] addSubview:_commentsView];//添加到window上,在视图以外 | |
| 149 | + UIWindow *window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds]; | |
| 150 | + [window addSubview:_commentsView];//添加到window上,在视图以外 | |
| 140 | 151 | [_commentText becomeFirstResponder]; |
| 141 | 152 | } |
| 142 | 153 | |
| ... | ... | @@ -149,10 +160,51 @@ typedef NS_ENUM(NSInteger, PopType) {//弹窗类型 |
| 149 | 160 | - (BOOL)textFieldShouldReturn:(UITextField *)textField |
| 150 | 161 | { |
| 151 | 162 | if (![textField.text isEqualToString:@""]) { |
| 152 | - //send message | |
| 153 | - NSLog(@"send message"); | |
| 154 | - [[CNLiveChatManager sharedCNLiveChatManager] sendMessage:textField.text type:CNLive_ConversationType_CHATROOM targetId:@"123" success:^(CNLiveChatMessage *message) { | |
| 155 | - NSLog(@"msgid:%@,tagid:%@,content:%@",message.messageId,message.targetId,message.messageContent); | |
| 163 | + | |
| 164 | + NSDictionary *dic; | |
| 165 | + if(self.barrageSwitch.isOn){ | |
| 166 | + //开启横屏弹幕 | |
| 167 | + dic = @{message_barrage:@"1",message_content:textField.text}; | |
| 168 | + }else | |
| 169 | + { | |
| 170 | + dic = @{message_barrage:@"0",message_content:textField.text}; | |
| 171 | + } | |
| 172 | + weakself | |
| 173 | + NSString *message = [Tools dictionaryToJson:dic]; | |
| 174 | + [[CNLiveChatManager sharedCNLiveChatManager] sendMessage:message type:CNLive_ConversationType_CHATROOM targetId:@"1234" success:^(CNLiveChatMessage *message) { | |
| 175 | + strongself | |
| 176 | + NSDictionary *JSONDic = [Tools dictionaryWithJsonString:message.messageContent]; | |
| 177 | + NSString *content = [JSONDic objectForKey:message_content]; | |
| 178 | + | |
| 179 | + //将消息显示到列表中 | |
| 180 | + chatMsgModel *model = [[chatMsgModel alloc] init]; | |
| 181 | + model.name = message.userInfo.name; | |
| 182 | + model.content = content; | |
| 183 | + model.ID = message.targetId; | |
| 184 | + model.icon = message.userInfo.portraitUri; | |
| 185 | + model.cellWidth = self.chatTableView.width - 20; | |
| 186 | + [self.chatMsgArray addObject:model]; | |
| 187 | + [self.chatTableView reloadData]; | |
| 188 | + NSInteger section = [self.chatTableView numberOfSections]; | |
| 189 | + if (section < 1) return; | |
| 190 | + NSInteger row = [self.chatTableView numberOfRowsInSection:section - 1]; | |
| 191 | + if (row < 1) return; | |
| 192 | + NSIndexPath *indexPath = [NSIndexPath indexPathForRow:row - 1 inSection:section - 1]; | |
| 193 | + [self.chatTableView scrollToRowAtIndexPath:indexPath atScrollPosition:UITableViewScrollPositionBottom animated:YES]; | |
| 194 | + [self.chatTableView reloadData]; | |
| 195 | + | |
| 196 | + NSInteger isBarrage = [[JSONDic objectForKey:message_barrage] integerValue]; | |
| 197 | + | |
| 198 | + if (isBarrage) {//此条消息飘弹幕 | |
| 199 | + | |
| 200 | + chatMsgModel *barrageModel = [[chatMsgModel alloc] init]; | |
| 201 | + barrageModel.name = message.userInfo.name; | |
| 202 | + barrageModel.content = content; | |
| 203 | + barrageModel.icon = message.userInfo.portraitUri; | |
| 204 | + | |
| 205 | + [self.chatManager addAnimationWithModel:barrageModel animContentView:self.animationBaseView]; | |
| 206 | + } | |
| 207 | + | |
| 156 | 208 | } error:^(CNLiveChatErrorCode errors, NSString *messageId, NSString *targetId) { |
| 157 | 209 | NSLog(@"%@",messageId); |
| 158 | 210 | }]; |
| ... | ... | @@ -165,24 +217,26 @@ typedef NS_ENUM(NSInteger, PopType) {//弹窗类型 |
| 165 | 217 | #pragma mark - bottomBtnActionDelegate |
| 166 | 218 | - (void)bottomActionWithType:(BtnClickType)btnType button:(UIButton *)button |
| 167 | 219 | { |
| 220 | + [[LVCAnimationManager shareManager] suspend]; | |
| 221 | + | |
| 168 | 222 | switch (btnType) { |
| 169 | 223 | case BtnClickTypeChat: |
| 170 | 224 | { |
| 171 | 225 | self.popType = PopTypeChat; |
| 172 | 226 | |
| 173 | 227 | [self showCommentText]; |
| 174 | - [[LVCAnimationManager shareManager] suspend]; | |
| 175 | 228 | } |
| 176 | 229 | break; |
| 177 | 230 | case BtnClickTypePriChat: |
| 178 | 231 | { |
| 179 | 232 | self.popType = PopTypePriMessage; |
| 233 | + [self hiddenView:YES]; | |
| 234 | + [self showPrivateView]; | |
| 180 | 235 | } |
| 181 | 236 | break; |
| 182 | 237 | case BtnClickTypeGift: |
| 183 | 238 | { |
| 184 | 239 | self.popType = PopTypeGift; |
| 185 | - [[LVCAnimationManager shareManager] suspend]; | |
| 186 | 240 | [self hiddenView:YES]; |
| 187 | 241 | [self addSubview:self.giftListView]; |
| 188 | 242 | self.giftListView.frame = CGRectMake(0, SCREEN_HEIGHT - 250, SCREEN_WIDTH, 250); |
| ... | ... | @@ -194,6 +248,14 @@ typedef NS_ENUM(NSInteger, PopType) {//弹窗类型 |
| 194 | 248 | } |
| 195 | 249 | } |
| 196 | 250 | |
| 251 | +- (void)showPrivateView | |
| 252 | +{ | |
| 253 | + PrivateView *privateView = [PrivateView privateView]; | |
| 254 | + privateView.backgroundColor = [UIColor yellowColor]; | |
| 255 | + [self addSubview:privateView]; | |
| 256 | + self.giftPopView = privateView; | |
| 257 | +} | |
| 258 | + | |
| 197 | 259 | - (void)hiddenView:(BOOL)isHidden |
| 198 | 260 | { |
| 199 | 261 | self.bottomToolView.hidden = isHidden; |
| ... | ... | @@ -206,6 +268,8 @@ typedef NS_ENUM(NSInteger, PopType) {//弹窗类型 |
| 206 | 268 | */ |
| 207 | 269 | - (void)clearCurrentPopView |
| 208 | 270 | { |
| 271 | + [[LVCAnimationManager shareManager] resume]; | |
| 272 | + | |
| 209 | 273 | switch (self.popType) { |
| 210 | 274 | case PopTypeGift: |
| 211 | 275 | { |
| ... | ... | @@ -213,7 +277,6 @@ typedef NS_ENUM(NSInteger, PopType) {//弹窗类型 |
| 213 | 277 | |
| 214 | 278 | self.giftPopView.frame = CGRectMake(0, SCREEN_HEIGHT, SCREEN_WIDTH, SCREEN_HEIGHT); |
| 215 | 279 | [self hiddenView:NO]; |
| 216 | - [[LVCAnimationManager shareManager] resume]; | |
| 217 | 280 | } completion:^(BOOL finished) { |
| 218 | 281 | }]; |
| 219 | 282 | } |
| ... | ... | @@ -221,12 +284,16 @@ typedef NS_ENUM(NSInteger, PopType) {//弹窗类型 |
| 221 | 284 | case PopTypeChat: |
| 222 | 285 | { |
| 223 | 286 | [self.commentText resignFirstResponder]; |
| 224 | - [[LVCAnimationManager shareManager] resume]; | |
| 225 | 287 | } |
| 226 | 288 | break; |
| 227 | 289 | case PopTypePriMessage: |
| 228 | 290 | { |
| 229 | - | |
| 291 | + [UIView animateWithDuration:0.25 animations:^{ | |
| 292 | + | |
| 293 | + self.giftPopView.frame = CGRectMake(0, SCREEN_HEIGHT, SCREEN_WIDTH, SCREEN_HEIGHT); | |
| 294 | + [self hiddenView:NO]; | |
| 295 | + } completion:^(BOOL finished) { | |
| 296 | + }]; | |
| 230 | 297 | } |
| 231 | 298 | break; |
| 232 | 299 | default: |
| ... | ... | @@ -238,6 +305,7 @@ typedef NS_ENUM(NSInteger, PopType) {//弹窗类型 |
| 238 | 305 | #pragma mark - buttonClick触摸屏幕关闭方法 |
| 239 | 306 | - (void)tapGestureClick:(UITapGestureRecognizer *)gesture |
| 240 | 307 | { |
| 308 | +// NSLog(@" tap gesture%@",gesture.view); | |
| 241 | 309 | [[LVCAnimationManager shareManager] bubblingWithCenterPoint:CGPointMake(SCREEN_WIDTH - 50, SCREEN_HEIGHT - 50) toView:self.animationBaseView]; |
| 242 | 310 | [self clearCurrentPopView]; |
| 243 | 311 | } |
| ... | ... | @@ -252,10 +320,29 @@ typedef NS_ENUM(NSInteger, PopType) {//弹窗类型 |
| 252 | 320 | [self textFieldShouldReturn:self.commentText]; |
| 253 | 321 | } |
| 254 | 322 | |
| 323 | +- (void)barrageSiwthChange:(UISwitch *)barrageSwitch | |
| 324 | +{ | |
| 325 | + if (barrageSwitch.isOn) { | |
| 326 | + _commentText.placeholder = @"1视讯币/条"; | |
| 327 | + }else | |
| 328 | + { | |
| 329 | + _commentText.placeholder = @"和大家说点什么吧"; | |
| 330 | + } | |
| 331 | +} | |
| 332 | + | |
| 255 | 333 | #pragma mark - userDetailDelegate聊天室列表个人信息 |
| 256 | 334 | - (void)userClickWithModel:(chatMsgModel *)model |
| 257 | 335 | { |
| 258 | 336 | NSLog(@"点击人:%@",model.name); |
| 337 | + userInfoModel *userModel = [[userInfoModel alloc ]init]; | |
| 338 | + userModel.name = model.name; | |
| 339 | + userModel.icon = model.icon; | |
| 340 | + userModel.sign = model.content;//@"哈哈啊哈哈啊哈哈,这是我的签名~"; | |
| 341 | + userModel.uId = @"123124"; | |
| 342 | + [Tools showBouncedWithModel:userModel callBackBlock:^(UIView * _Nullable bounceView) { | |
| 343 | + NSLog(@"%@",bounceView); | |
| 344 | + | |
| 345 | + }]; | |
| 259 | 346 | } |
| 260 | 347 | |
| 261 | 348 | #pragma mark - CNLiveChatManagerDelegate |
| ... | ... | @@ -299,7 +386,42 @@ typedef NS_ENUM(NSInteger, PopType) {//弹窗类型 |
| 299 | 386 | */ |
| 300 | 387 | - (void)onReceived:(CNLiveChatMessage *)message |
| 301 | 388 | { |
| 302 | - NSLog(@"onReceived msg:%@",message.messageContent); | |
| 389 | +// NSLog(@"onReceived"); | |
| 390 | + NSDictionary *JSONDic = [Tools dictionaryWithJsonString:message.messageContent]; | |
| 391 | + NSString *content = [JSONDic objectForKey:message_content]; | |
| 392 | + | |
| 393 | + //将消息显示到列表中 | |
| 394 | + chatMsgModel *model = [[chatMsgModel alloc] init]; | |
| 395 | + model.name = message.userInfo.name; | |
| 396 | + model.content = content; | |
| 397 | + model.ID = message.targetId; | |
| 398 | + model.icon = message.userInfo.portraitUri; | |
| 399 | + model.cellWidth = self.chatTableView.width - 20; | |
| 400 | + [self.chatMsgArray addObject:model]; | |
| 401 | + [self.chatTableView reloadData]; | |
| 402 | + | |
| 403 | + NSInteger section = [self.chatTableView numberOfSections]; | |
| 404 | + if (section < 1) return; | |
| 405 | + NSInteger row = [self.chatTableView numberOfRowsInSection:section - 1]; | |
| 406 | + if (row < 1) return; | |
| 407 | + NSIndexPath *indexPath = [NSIndexPath indexPathForRow:row - 1 inSection:section - 1]; | |
| 408 | + [self.chatTableView scrollToRowAtIndexPath:indexPath atScrollPosition:UITableViewScrollPositionBottom animated:YES]; | |
| 409 | + [self.chatTableView reloadData]; | |
| 410 | + | |
| 411 | + NSInteger isBarrage = [[JSONDic objectForKey:message_barrage] integerValue]; | |
| 412 | + | |
| 413 | + if (isBarrage) {//此条消息飘弹幕 | |
| 414 | + | |
| 415 | + chatMsgModel *barrageModel = [[chatMsgModel alloc] init]; | |
| 416 | + barrageModel.name = message.userInfo.name; | |
| 417 | + barrageModel.content = content; | |
| 418 | + barrageModel.icon = message.userInfo.portraitUri; | |
| 419 | +// self.barrageView = [self.barrManager addAnimationWithModel:barrageModel animContentView:self.animationBaseView]; | |
| 420 | + [self.chatManager addAnimationWithModel:barrageModel animContentView:self.animationBaseView];//self.barrageView = | |
| 421 | + | |
| 422 | + self.animationBaseView.delegate = self.chatManager; | |
| 423 | +// self.animationBaseView.barrageView = self.barrageView; | |
| 424 | + } | |
| 303 | 425 | } |
| 304 | 426 | |
| 305 | 427 | /** |
| ... | ... | @@ -386,13 +508,11 @@ typedef NS_ENUM(NSInteger, PopType) {//弹窗类型 |
| 386 | 508 | return _scrollView; |
| 387 | 509 | } |
| 388 | 510 | |
| 389 | -- (UIView *)animationBaseView | |
| 511 | +- (AnimationBaseView *)animationBaseView | |
| 390 | 512 | { |
| 391 | 513 | if (!_animationBaseView) |
| 392 | 514 | { |
| 393 | - _animationBaseView = [[UIView alloc] initWithFrame:CGRectMake(self.scrollView.width, 0, self.scrollView.width, self.scrollView.height)]; | |
| 394 | - _animationBaseView.backgroundColor = [UIColor redColor]; | |
| 395 | - _animationBaseView.clipsToBounds = YES; | |
| 515 | + _animationBaseView = [[AnimationBaseView alloc] initWithFrame:CGRectMake(self.scrollView.width, 0, self.scrollView.width, self.scrollView.height)]; | |
| 396 | 516 | } |
| 397 | 517 | return _animationBaseView; |
| 398 | 518 | } |
| ... | ... | @@ -412,7 +532,12 @@ typedef NS_ENUM(NSInteger, PopType) {//弹窗类型 |
| 412 | 532 | { |
| 413 | 533 | if (!_barrageSwitch) |
| 414 | 534 | { |
| 415 | - _barrageSwitch = [[UISwitch alloc] init]; | |
| 535 | + _barrageSwitch = [[UISwitch alloc] initWithFrame:CGRectMake(10, 10, 40, 30)]; | |
| 536 | + _barrageSwitch.tintColor = [UIColor orangeColor]; | |
| 537 | + _barrageSwitch.onTintColor = [UIColor orangeColor]; | |
| 538 | + _barrageSwitch.thumbTintColor = [UIColor lightGrayColor]; | |
| 539 | + _barrageSwitch.centerY = _commentsView.height * 0.5; | |
| 540 | + [_barrageSwitch addTarget:self action:@selector(barrageSiwthChange:) forControlEvents:UIControlEventValueChanged]; | |
| 416 | 541 | } |
| 417 | 542 | return _barrageSwitch; |
| 418 | 543 | } |
| ... | ... | @@ -448,6 +573,7 @@ typedef NS_ENUM(NSInteger, PopType) {//弹窗类型 |
| 448 | 573 | [tableView registerClass:[chatListCell class] forCellReuseIdentifier:NSStringFromClass([chatListCell class])]; |
| 449 | 574 | tableView.showsVerticalScrollIndicator = NO; |
| 450 | 575 | tableView.showsHorizontalScrollIndicator = NO; |
| 576 | + tableView.bounces = NO; | |
| 451 | 577 | tableView.backgroundColor = [UIColor clearColor]; |
| 452 | 578 | tableView.separatorStyle = UITableViewCellSeparatorStyleNone; |
| 453 | 579 | _chatTableView = tableView; |
| ... | ... | @@ -460,15 +586,15 @@ typedef NS_ENUM(NSInteger, PopType) {//弹窗类型 |
| 460 | 586 | if (!_chatMsgArray) { |
| 461 | 587 | |
| 462 | 588 | _chatMsgArray = [NSMutableArray array]; |
| 463 | - NSArray *names = [NSArray arrayWithObjects:@"张旭",@"老大",@"老六",@"什么人",@"金光",@"银光",@"阳光", nil]; | |
| 464 | - NSArray *contents = [NSArray arrayWithObjects:@"阿萨德请问发群里发",@"阿萨德请问发群里发发染发我if顽皮的发球局平均分配WiF",@"阿萨德请问发群里发发染发我if顽皮的发球局平均分配WiFi我if为打破我姐夫我批发价为破房间我批发价我批发价为 爱神的箭怕我的哦期",@"里发发染发我if顽",@"金光神的箭怕我的哦期间",@"银光",@"阳光神的箭怕我的哦期间", nil]; | |
| 465 | - for (int i = 0 ; i < names.count; i ++) { | |
| 466 | - chatMsgModel *model = [[chatMsgModel alloc] init]; | |
| 467 | - model.name = names[i]; | |
| 468 | - model.content = contents[i]; | |
| 469 | - model.cellWidth = self.chatTableView.width - 20; | |
| 470 | - [self.chatMsgArray addObject:model]; | |
| 471 | - } | |
| 589 | +// NSArray *names = [NSArray arrayWithObjects:@"张旭",@"老大",@"老六",@"什么人",@"金光",@"银光",@"阳光", nil]; | |
| 590 | +// NSArray *contents = [NSArray arrayWithObjects:@"阿萨德请问发群里发",@"阿萨德请问发群里发发染发我if顽皮的发球局平均分配WiF",@"阿萨德请问发群里发发染发我if顽皮的发球局平均分配WiFi我if为打破我姐夫我批发价为破房间我批发价我批发价为 爱神的箭怕我的哦期",@"里发发染发我if顽",@"金光神的箭怕我的哦期间",@"银光",@"阳光神的箭怕我的哦期间", nil]; | |
| 591 | +// for (int i = 0 ; i < names.count; i ++) { | |
| 592 | +// chatMsgModel *model = [[chatMsgModel alloc] init]; | |
| 593 | +// model.name = names[i]; | |
| 594 | +// model.content = contents[i]; | |
| 595 | +// model.cellWidth = self.chatTableView.width - 20; | |
| 596 | +// [self.chatMsgArray addObject:model]; | |
| 597 | +// } | |
| 472 | 598 | } |
| 473 | 599 | return _chatMsgArray; |
| 474 | 600 | } |
| ... | ... | @@ -503,6 +629,22 @@ typedef NS_ENUM(NSInteger, PopType) {//弹窗类型 |
| 503 | 629 | return _giftListView; |
| 504 | 630 | } |
| 505 | 631 | |
| 632 | +//- (BarrageManager *)barrManager | |
| 633 | +//{ | |
| 634 | +// if (!_barrManager) | |
| 635 | +// { | |
| 636 | +// _barrManager = [BarrageManager sharedManager]; | |
| 637 | +// } | |
| 638 | +// return _barrManager; | |
| 639 | +//} | |
| 640 | +- (ChatBarrageManager *)chatManager | |
| 641 | +{ | |
| 642 | + if (!_chatManager) | |
| 643 | + { | |
| 644 | + _chatManager = [ChatBarrageManager sharedManager]; | |
| 645 | + } | |
| 646 | + return _chatManager; | |
| 647 | +} | |
| 506 | 648 | /* |
| 507 | 649 | // Only override drawRect: if you perform custom drawing. |
| 508 | 650 | // An empty implementation adversely affects performance during animation. | ... | ... |
LiveVideoCloud/LiveVideoCloud/Classes/Sections/InteractionSections/PrivateView/PrivateView.h
0 → 100644
LiveVideoCloud/LiveVideoCloud/Classes/Sections/InteractionSections/PrivateView/PrivateView.m
0 → 100644
| 1 | +// | |
| 2 | +// PrivateView.m | |
| 3 | +// LiveVideoCloud | |
| 4 | +// | |
| 5 | +// Created by 张旭 on 2017/3/23. | |
| 6 | +// Copyright © 2017年 cnlive. All rights reserved. | |
| 7 | +// | |
| 8 | + | |
| 9 | +#import "PrivateView.h" | |
| 10 | + | |
| 11 | +@implementation PrivateView | |
| 12 | + | |
| 13 | ++ (instancetype)privateView | |
| 14 | +{ | |
| 15 | + return [[PrivateView alloc] initWithFrame:CGRectMake(0, SCREEN_HEIGHT - 300, SCREEN_WIDTH, 300)]; | |
| 16 | +} | |
| 17 | +/* | |
| 18 | +// Only override drawRect: if you perform custom drawing. | |
| 19 | +// An empty implementation adversely affects performance during animation. | |
| 20 | +- (void)drawRect:(CGRect)rect { | |
| 21 | + // Drawing code | |
| 22 | +} | |
| 23 | +*/ | |
| 24 | + | |
| 25 | +@end | ... | ... |
LiveVideoCloud/LiveVideoCloud/Classes/Sections/InteractionSections/userInfoModel.h
0 → 100644
| 1 | +// | |
| 2 | +// userInfoModel.h | |
| 3 | +// LiveVideoCloud | |
| 4 | +// | |
| 5 | +// Created by 张旭 on 2017/3/23. | |
| 6 | +// Copyright © 2017年 cnlive. All rights reserved. | |
| 7 | +// | |
| 8 | + | |
| 9 | +#import "BaseModel.h" | |
| 10 | + | |
| 11 | +@interface userInfoModel : BaseModel | |
| 12 | + | |
| 13 | +@property (nonatomic ,copy) NSString * _Nullable icon; | |
| 14 | +@property (nonatomic ,copy) NSString * _Nullable name; | |
| 15 | +@property (nonatomic ,copy) NSString * _Nullable sign; | |
| 16 | +@property (nonatomic ,copy) NSString * _Nullable uId; | |
| 17 | + | |
| 18 | + | |
| 19 | +@end | ... | ... |
LiveVideoCloud/LiveVideoCloud/Classes/Sections/InteractionSections/userInfoModel.m
0 → 100644
LiveVideoCloud/LiveVideoCloud/UtilKits/Category/UIImageView+ZXExtension.h
0 → 100755
LiveVideoCloud/LiveVideoCloud/UtilKits/Category/UIImageView+ZXExtension.m
0 → 100755
| 1 | +// | |
| 2 | +// UIImageView+ZXExtension.m | |
| 3 | +// 百思LiveVideoCloud姐 | |
| 4 | +// | |
| 5 | +// Created by mac on 16/8/31. | |
| 6 | +// Copyright © 2016年 mac. All rights reserved. | |
| 7 | +// | |
| 8 | + | |
| 9 | +#import "UIImageView+ZXExtension.h" | |
| 10 | +#import "UIImageView+WebCache.h" | |
| 11 | + | |
| 12 | +static NSString *defaultUserIcon = @"defaultUserIcon"; | |
| 13 | + | |
| 14 | +@implementation UIImageView (ZXExtension) | |
| 15 | +- (void)zx_setHeader:(NSString *)url | |
| 16 | +{ | |
| 17 | + [self zx_setCircleHeader:url]; | |
| 18 | +} | |
| 19 | + | |
| 20 | +- (void)zx_setRectHeader:(NSString *)url | |
| 21 | +{ | |
| 22 | + [self sd_setImageWithURL:[NSURL URLWithString:url] placeholderImage:[UIImage imageNamed:defaultUserIcon]]; | |
| 23 | +} | |
| 24 | + | |
| 25 | +- (void)zx_setCircleHeader:(NSString *)url | |
| 26 | +{ | |
| 27 | + weakself; | |
| 28 | + UIImage *placeholder = [[UIImage imageNamed:defaultUserIcon] zx_circleImage]; | |
| 29 | + [self sd_setImageWithURL:[NSURL URLWithString:url] placeholderImage:placeholder completed: | |
| 30 | + ^(UIImage *image, NSError *error, SDImageCacheType cacheType, NSURL *imageURL) { | |
| 31 | + // 如果图片下载失败,就不做任何处理,按照默认的做法:会显示占位图片 | |
| 32 | + if (image == nil) return; | |
| 33 | + | |
| 34 | + weakSelf.image = [image zx_circleImage]; | |
| 35 | + }]; | |
| 36 | +} | |
| 37 | + | |
| 38 | +@end | ... | ... |
LiveVideoCloud/LiveVideoCloud/UtilKits/UtilKits.h
| ... | ... | @@ -17,6 +17,8 @@ |
| 17 | 17 | #import "UIColor+HexString.h" //生成新颜色 |
| 18 | 18 | #import "UIImage+ScaleImageSize.h" //缩放图片 |
| 19 | 19 | #import "UILabel+labelFitSize.h" //UILabel自适应大小 |
| 20 | +#import "UIImageView+ZXExtension.h" //圆角图片 | |
| 21 | +#import "Tools.h" //工具类 | |
| 20 | 22 | |
| 21 | 23 | #import "ZXDeviceInfo.h" //设备信息 |
| 22 | 24 | #import "ZXConst.h" //常量 |
| ... | ... | @@ -24,4 +26,5 @@ |
| 24 | 26 | #import "Macros.h" //宏定义 |
| 25 | 27 | |
| 26 | 28 | |
| 29 | + | |
| 27 | 30 | #endif /* UtilKits_h */ | ... | ... |
LiveVideoCloud/LiveVideoCloud/animation.xcassets/Interaction/defaultUserIcon.imageset/Contents.json
0 → 100644
LiveVideoCloud/LiveVideoCloud/animation.xcassets/Interaction/defaultUserIcon.imageset/贡献榜小头像.png
0 → 100644
5.71 KB
LiveVideoCloud/LiveVideoCloud/animation.xcassets/Interaction/private chat.imageset/1 2.png deleted
100644 → 0
7.63 KB
LiveVideoCloud/LiveVideoCloud/animation.xcassets/Interaction/private chat.imageset/Contents.json renamed to LiveVideoCloud/LiveVideoCloud/animation.xcassets/Interaction/privateChat.png.imageset/Contents.json
LiveVideoCloud/LiveVideoCloud/animation.xcassets/Interaction/privateChat.png.imageset/privateChat.png
0 → 100644
6.61 KB