Commit 7dc06f42077b25f3e9ed2d4e87769e28acb1726f

Authored by 张旭
1 parent 7b964133

动画未完成

Showing 30 changed files with 939 additions and 208 deletions
LiveVideoCloud/LiveVideoCloud.xcodeproj/project.pbxproj
... ... @@ -128,10 +128,14 @@
128 128 D22830FF1E77C69E00627701 /* GiftListView.m in Sources */ = {isa = PBXBuildFile; fileRef = D22830FE1E77C69E00627701 /* GiftListView.m */; };
129 129 D22831021E77D83C00627701 /* GiftModelView.m in Sources */ = {isa = PBXBuildFile; fileRef = D22831011E77D83C00627701 /* GiftModelView.m */; };
130 130 D22831091E77D8D500627701 /* GiftModel.m in Sources */ = {isa = PBXBuildFile; fileRef = D22831081E77D8D500627701 /* GiftModel.m */; };
  131 + D25530001E7909AC00DF38A5 /* GiftAnimOperation.m in Sources */ = {isa = PBXBuildFile; fileRef = D2552FFF1E7909AC00DF38A5 /* GiftAnimOperation.m */; };
  132 + D25530031E79115100DF38A5 /* AnimQueueManager.m in Sources */ = {isa = PBXBuildFile; fileRef = D25530021E79115100DF38A5 /* AnimQueueManager.m */; };
  133 + D25530061E7911A800DF38A5 /* GiftAnimationAction.m in Sources */ = {isa = PBXBuildFile; fileRef = D25530051E7911A800DF38A5 /* GiftAnimationAction.m */; };
  134 + D25530091E791A7100DF38A5 /* GiftComboView.m in Sources */ = {isa = PBXBuildFile; fileRef = D25530081E791A7100DF38A5 /* GiftComboView.m */; };
  135 + D255300C1E793F8200DF38A5 /* NHFighterView+animDelegagte.m in Sources */ = {isa = PBXBuildFile; fileRef = D255300B1E793F8200DF38A5 /* NHFighterView+animDelegagte.m */; };
131 136 D2575C461E76857100E3A8FC /* LVCAnimationManager.m in Sources */ = {isa = PBXBuildFile; fileRef = D2575C451E76857100E3A8FC /* LVCAnimationManager.m */; };
132 137 D2575C4A1E7685DE00E3A8FC /* UIView+Bubbling.m in Sources */ = {isa = PBXBuildFile; fileRef = D2575C481E7685DE00E3A8FC /* UIView+Bubbling.m */; };
133 138 D2575C671E76A25400E3A8FC /* LVCInteractionController.m in Sources */ = {isa = PBXBuildFile; fileRef = D2575C661E76A25400E3A8FC /* LVCInteractionController.m */; };
134   - D2575C6B1E76A45400E3A8FC /* LVCGiftManager.m in Sources */ = {isa = PBXBuildFile; fileRef = D2575C6A1E76A45400E3A8FC /* LVCGiftManager.m */; };
135 139 D2575C7A1E76A4F300E3A8FC /* NHCarViews.m in Sources */ = {isa = PBXBuildFile; fileRef = D2575C6F1E76A4F300E3A8FC /* NHCarViews.m */; };
136 140 D2575C7B1E76A4F300E3A8FC /* NHCarViews.xib in Resources */ = {isa = PBXBuildFile; fileRef = D2575C701E76A4F300E3A8FC /* NHCarViews.xib */; };
137 141 D2575C7C1E76A4F300E3A8FC /* NHFighterView.nib in Resources */ = {isa = PBXBuildFile; fileRef = D2575C721E76A4F300E3A8FC /* NHFighterView.nib */; };
... ... @@ -433,14 +437,22 @@
433 437 D22831011E77D83C00627701 /* GiftModelView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GiftModelView.m; sourceTree = "<group>"; };
434 438 D22831071E77D8D500627701 /* GiftModel.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GiftModel.h; sourceTree = "<group>"; };
435 439 D22831081E77D8D500627701 /* GiftModel.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GiftModel.m; sourceTree = "<group>"; };
436   - D2575C441E76857100E3A8FC /* LVCAnimationManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LVCAnimationManager.h; sourceTree = "<group>"; };
437   - D2575C451E76857100E3A8FC /* LVCAnimationManager.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = LVCAnimationManager.m; sourceTree = "<group>"; };
  440 + D2552FFE1E7909AC00DF38A5 /* GiftAnimOperation.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GiftAnimOperation.h; sourceTree = "<group>"; };
  441 + D2552FFF1E7909AC00DF38A5 /* GiftAnimOperation.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GiftAnimOperation.m; sourceTree = "<group>"; };
  442 + D25530011E79115100DF38A5 /* AnimQueueManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AnimQueueManager.h; sourceTree = "<group>"; };
  443 + D25530021E79115100DF38A5 /* AnimQueueManager.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AnimQueueManager.m; sourceTree = "<group>"; };
  444 + D25530041E7911A800DF38A5 /* GiftAnimationAction.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GiftAnimationAction.h; sourceTree = "<group>"; };
  445 + D25530051E7911A800DF38A5 /* GiftAnimationAction.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GiftAnimationAction.m; sourceTree = "<group>"; };
  446 + D25530071E791A7100DF38A5 /* GiftComboView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GiftComboView.h; sourceTree = "<group>"; };
  447 + D25530081E791A7100DF38A5 /* GiftComboView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GiftComboView.m; sourceTree = "<group>"; };
  448 + D255300A1E793F8200DF38A5 /* NHFighterView+animDelegagte.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NHFighterView+animDelegagte.h"; sourceTree = "<group>"; };
  449 + D255300B1E793F8200DF38A5 /* NHFighterView+animDelegagte.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "NHFighterView+animDelegagte.m"; sourceTree = "<group>"; };
  450 + D2575C441E76857100E3A8FC /* LVCAnimationManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = LVCAnimationManager.h; path = ../LVCAnimationManager.h; sourceTree = "<group>"; };
  451 + D2575C451E76857100E3A8FC /* LVCAnimationManager.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = LVCAnimationManager.m; path = ../LVCAnimationManager.m; sourceTree = "<group>"; };
438 452 D2575C481E7685DE00E3A8FC /* UIView+Bubbling.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "UIView+Bubbling.m"; sourceTree = "<group>"; };
439 453 D2575C491E7685DE00E3A8FC /* UIView+Bubbling.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "UIView+Bubbling.h"; sourceTree = "<group>"; };
440 454 D2575C651E76A25400E3A8FC /* LVCInteractionController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LVCInteractionController.h; sourceTree = "<group>"; };
441 455 D2575C661E76A25400E3A8FC /* LVCInteractionController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = LVCInteractionController.m; sourceTree = "<group>"; };
442   - D2575C691E76A45400E3A8FC /* LVCGiftManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LVCGiftManager.h; sourceTree = "<group>"; };
443   - D2575C6A1E76A45400E3A8FC /* LVCGiftManager.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = LVCGiftManager.m; sourceTree = "<group>"; };
444 456 D2575C6D1E76A4F300E3A8FC /* NHCarView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NHCarView.h; sourceTree = "<group>"; };
445 457 D2575C6E1E76A4F300E3A8FC /* NHCarViews.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NHCarViews.h; sourceTree = "<group>"; };
446 458 D2575C6F1E76A4F300E3A8FC /* NHCarViews.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = NHCarViews.m; sourceTree = "<group>"; };
... ... @@ -1221,8 +1233,6 @@
1221 1233 D2575C661E76A25400E3A8FC /* LVCInteractionController.m */,
1222 1234 D2575C681E76A42B00E3A8FC /* Gift */,
1223 1235 D2575C471E7685C500E3A8FC /* heartAnimation */,
1224   - D2575C441E76857100E3A8FC /* LVCAnimationManager.h */,
1225   - D2575C451E76857100E3A8FC /* LVCAnimationManager.m */,
1226 1236 );
1227 1237 path = InteractionSections;
1228 1238 sourceTree = "<group>";
... ... @@ -1232,6 +1242,8 @@
1232 1242 children = (
1233 1243 D2575C491E7685DE00E3A8FC /* UIView+Bubbling.h */,
1234 1244 D2575C481E7685DE00E3A8FC /* UIView+Bubbling.m */,
  1245 + D2575C441E76857100E3A8FC /* LVCAnimationManager.h */,
  1246 + D2575C451E76857100E3A8FC /* LVCAnimationManager.m */,
1235 1247 );
1236 1248 path = heartAnimation;
1237 1249 sourceTree = "<group>";
... ... @@ -1239,8 +1251,14 @@
1239 1251 D2575C681E76A42B00E3A8FC /* Gift */ = {
1240 1252 isa = PBXGroup;
1241 1253 children = (
1242   - D2575C691E76A45400E3A8FC /* LVCGiftManager.h */,
1243   - D2575C6A1E76A45400E3A8FC /* LVCGiftManager.m */,
  1254 + D25530071E791A7100DF38A5 /* GiftComboView.h */,
  1255 + D25530081E791A7100DF38A5 /* GiftComboView.m */,
  1256 + D25530041E7911A800DF38A5 /* GiftAnimationAction.h */,
  1257 + D25530051E7911A800DF38A5 /* GiftAnimationAction.m */,
  1258 + D25530011E79115100DF38A5 /* AnimQueueManager.h */,
  1259 + D25530021E79115100DF38A5 /* AnimQueueManager.m */,
  1260 + D2552FFE1E7909AC00DF38A5 /* GiftAnimOperation.h */,
  1261 + D2552FFF1E7909AC00DF38A5 /* GiftAnimOperation.m */,
1244 1262 D22830F51E77C24900627701 /* GiftViews */,
1245 1263 D2575C6C1E76A4F300E3A8FC /* GiftResource */,
1246 1264 D22831061E77D8D500627701 /* GiftModel */,
... ... @@ -1251,6 +1269,8 @@
1251 1269 D2575C6C1E76A4F300E3A8FC /* GiftResource */ = {
1252 1270 isa = PBXGroup;
1253 1271 children = (
  1272 + D255300A1E793F8200DF38A5 /* NHFighterView+animDelegagte.h */,
  1273 + D255300B1E793F8200DF38A5 /* NHFighterView+animDelegagte.m */,
1254 1274 D2575C6D1E76A4F300E3A8FC /* NHCarView.h */,
1255 1275 D2575C6E1E76A4F300E3A8FC /* NHCarViews.h */,
1256 1276 D2575C6F1E76A4F300E3A8FC /* NHCarViews.m */,
... ... @@ -1524,6 +1544,7 @@
1524 1544 isa = PBXSourcesBuildPhase;
1525 1545 buildActionMask = 2147483647;
1526 1546 files = (
  1547 + D25530091E791A7100DF38A5 /* GiftComboView.m in Sources */,
1527 1548 D2029CC31E6EADE10027CD92 /* UIImageView+HighlightedWebCache.m in Sources */,
1528 1549 D22830FF1E77C69E00627701 /* GiftListView.m in Sources */,
1529 1550 D2029CC01E6EADE10027CD92 /* UIImage+GIF.m in Sources */,
... ... @@ -1575,6 +1596,7 @@
1575 1596 D2029CA21E6EADE10027CD92 /* MJRefreshAutoFooter.m in Sources */,
1576 1597 D2029CC71E6EADE10027CD92 /* SVIndefiniteAnimatedView.m in Sources */,
1577 1598 D2029CA31E6EADE10027CD92 /* MJRefreshBackFooter.m in Sources */,
  1599 + D255300C1E793F8200DF38A5 /* NHFighterView+animDelegagte.m in Sources */,
1578 1600 D2575C4A1E7685DE00E3A8FC /* UIView+Bubbling.m in Sources */,
1579 1601 D22831021E77D83C00627701 /* GiftModelView.m in Sources */,
1580 1602 D2029CA61E6EADE10027CD92 /* MJRefreshHeader.m in Sources */,
... ... @@ -1598,6 +1620,7 @@
1598 1620 D2575C461E76857100E3A8FC /* LVCAnimationManager.m in Sources */,
1599 1621 D2029C8A1E6EADE10027CD92 /* AFURLRequestSerialization.m in Sources */,
1600 1622 D2029D041E6EAE2E0027CD92 /* UILabel+ContentSize.m in Sources */,
  1623 + D25530031E79115100DF38A5 /* AnimQueueManager.m in Sources */,
1601 1624 D2029C871E6EADE10027CD92 /* AFHTTPSessionManager.m in Sources */,
1602 1625 D2029B861E6EAAA50027CD92 /* main.m in Sources */,
1603 1626 D2029C8C1E6EADE10027CD92 /* AFURLSessionManager.m in Sources */,
... ... @@ -1629,11 +1652,11 @@
1629 1652 D2029D001E6EAE2E0027CD92 /* NSNumber+ScaleHeight.m in Sources */,
1630 1653 D2888D9E1E6EBF1B003A77C8 /* LVCLiveViewController.m in Sources */,
1631 1654 D2029C951E6EADE10027CD92 /* UIWebView+AFNetworking.m in Sources */,
1632   - D2575C6B1E76A45400E3A8FC /* LVCGiftManager.m in Sources */,
1633 1655 D2029CBD1E6EADE10027CD92 /* SDWebImageManager.m in Sources */,
1634 1656 D2029CB41E6EADE10027CD92 /* UIView+MJExtension.m in Sources */,
1635 1657 D2029CA91E6EADE10027CD92 /* MJRefreshAutoStateFooter.m in Sources */,
1636 1658 D2029D061E6EAE2E0027CD92 /* UIView+Extension.m in Sources */,
  1659 + D25530001E7909AC00DF38A5 /* GiftAnimOperation.m in Sources */,
1637 1660 D2029C9D1E6EADE10027CD92 /* NSObject+MJClass.m in Sources */,
1638 1661 D2029CCF1E6EADE10027CD92 /* SearchHttp.m in Sources */,
1639 1662 810B65001E779B1F00133E15 /* MASConstraintMaker.m in Sources */,
... ... @@ -1642,6 +1665,7 @@
1642 1665 D2029BCC1E6EADD70027CD92 /* BaseView.m in Sources */,
1643 1666 D2888D941E6EB8B4003A77C8 /* LVCTabBar.m in Sources */,
1644 1667 D2888DB41E6EC154003A77C8 /* HomeViewController.m in Sources */,
  1668 + D25530061E7911A800DF38A5 /* GiftAnimationAction.m in Sources */,
1645 1669 D2029CD41E6EADE70027CD92 /* HttpService.m in Sources */,
1646 1670 );
1647 1671 runOnlyForDeploymentPostprocessing = 0;
... ...
LiveVideoCloud/LiveVideoCloud/Classes/Sections/InteractionSections/Gift/AnimQueueManager.h 0 → 100644
  1 +//
  2 +// AnimQueueManager.h
  3 +// LiveVideoCloud
  4 +//
  5 +// Created by 张旭 on 2017/3/15.
  6 +// Copyright © 2017年 cnlive. All rights reserved.
  7 +//
  8 +
  9 +#import <Foundation/Foundation.h>
  10 +
  11 +@class GiftModel;
  12 +@interface AnimQueueManager : NSObject
  13 +
  14 +@property (nonatomic, assign)NSInteger maxTop; //初始位置(需要根据显示设置最低位置在哪里)
  15 +//@property (nonatomic, strong)NSMutableArray *arGiftArray; //横幅的数量,用于轨道计算(现在结构是一维数组,因为轨道中的弹道只有1个,如果是多个的话需要变为二维数组)
  16 +
  17 +/**
  18 + 初始化管理类
  19 + @return 当前manager
  20 + */
  21 ++ (instancetype)sharedAnimQueueManager;
  22 +
  23 +/**
  24 + 根据实际model添加飞机横幅动画(火箭、飞机横幅动画为一个队列)
  25 +
  26 + @param animContentView 需要把动画view添加到的view
  27 + @param model modelobj
  28 + */
  29 +- (void)addAnimationWithModel:(GiftModel *)model animContentView:(UIView *)animContentView;
  30 +
  31 +@end
... ...
LiveVideoCloud/LiveVideoCloud/Classes/Sections/InteractionSections/Gift/AnimQueueManager.m 0 → 100644
  1 +//
  2 +// AnimQueueManager.m
  3 +// LiveVideoCloud
  4 +//
  5 +// Created by 张旭 on 2017/3/15.
  6 +// Copyright © 2017年 cnlive. All rights reserved.
  7 +//
  8 +
  9 +#import "AnimQueueManager.h"
  10 +#import "GiftAnimOperation.h"
  11 +#import "GiftModel.h"
  12 +
  13 +@interface AnimQueueManager ()
  14 +
  15 +@property (nonatomic, assign)NSInteger maxOperationCount; //并发数
  16 +@property (nonatomic,strong) NSOperationQueue *comboAnimationQueue; //连击动画队列
  17 +@property (nonatomic,strong) NSOperationQueue *expenAnimationQueue; //豪华礼物动画队列
  18 +
  19 +@end
  20 +
  21 +@implementation AnimQueueManager
  22 +
  23 +/**
  24 + 初始化管理类
  25 + @return 当前manager
  26 + */
  27 ++ (instancetype)sharedAnimQueueManager{
  28 +
  29 + static AnimQueueManager *manager;
  30 +
  31 + static dispatch_once_t onceToken;
  32 + dispatch_once(&onceToken, ^{
  33 + manager = [[AnimQueueManager alloc] init];
  34 + manager.maxOperationCount = 2;
  35 +// manager.arGiftArray = [NSMutableArray arrayWithObjects:@200,@240,@280, nil];
  36 + });
  37 + return manager;
  38 +}
  39 +
  40 +/**
  41 + 连击动画队列
  42 +
  43 + @return 队列obj
  44 + */
  45 +- (NSOperationQueue *)comboAnimationQueue{
  46 + if (_comboAnimationQueue == nil) {
  47 + _comboAnimationQueue = [[NSOperationQueue alloc] init];
  48 + _comboAnimationQueue.maxConcurrentOperationCount = 3;
  49 + }
  50 + return _comboAnimationQueue;
  51 +}
  52 +
  53 +/**
  54 + 豪华动画队列
  55 +
  56 + @return 队列obj
  57 + */
  58 +- (NSOperationQueue *)expenAnimationQueue{
  59 + if (_expenAnimationQueue == nil) {
  60 + _expenAnimationQueue = [[NSOperationQueue alloc] init];
  61 + _expenAnimationQueue.maxConcurrentOperationCount = 1;
  62 + }
  63 + return _expenAnimationQueue;
  64 +}
  65 +
  66 +/**
  67 + 根据实际model添加动画
  68 +
  69 + @param model modelobj
  70 + */
  71 +- (void)addAnimationWithModel:(GiftModel *)model animContentView:(UIView *)animContentView{
  72 +
  73 + GiftAnimOperation *op = [GiftAnimOperation addGiftAnimOperationWithGiftModel:model animContentView:animContentView maxTop:self.maxTop];
  74 + NSInteger index = self.comboAnimationQueue.operationCount;
  75 + NSLog(@"index:%zd",index);
  76 + switch (model.giftStyle) {
  77 + case GiftStylePorsch:
  78 + [self.expenAnimationQueue addOperation:op];
  79 + break;
  80 +// case GiftStyleFighter:
  81 +// [self.expenAnimationQueue addOperation:op];
  82 +// break;
  83 + case GiftStylePlane:
  84 + [self.expenAnimationQueue addOperation:op];
  85 + break;
  86 + case GiftStyleCombo:
  87 + {
  88 + [self.comboAnimationQueue addOperation:op];
  89 +// int i = rand()%4;
  90 +// op.name = i >0 ? @"张三_love" : @"李四_flower";//name imagename
  91 +// self.comboAnimationQueue.suspended;
  92 + }
  93 +
  94 + break;
  95 + default:
  96 + break;
  97 + }
  98 +}
  99 +
  100 +@end
... ...
LiveVideoCloud/LiveVideoCloud/Classes/Sections/InteractionSections/Gift/GiftAnimOperation.h 0 → 100644
  1 +//
  2 +// GiftAnimOperation.h
  3 +// LiveVideoCloud
  4 +//
  5 +// Created by 张旭 on 2017/3/15.
  6 +// Copyright © 2017年 cnlive. All rights reserved.
  7 +//
  8 +
  9 +#import <Foundation/Foundation.h>
  10 +#import <UIKit/UIKit.h>
  11 +
  12 +@class GiftModel;
  13 +
  14 +@interface GiftAnimOperation : NSOperation
  15 +
  16 ++ (GiftAnimOperation *)addGiftAnimOperationWithGiftModel:(GiftModel *)model animContentView:(UIView *)animContentView maxTop:(NSInteger)maxTop;
  17 +
  18 +@end
... ...
LiveVideoCloud/LiveVideoCloud/Classes/Sections/InteractionSections/Gift/GiftAnimOperation.m 0 → 100644
  1 +//
  2 +// GiftAnimOperation.m
  3 +// LiveVideoCloud
  4 +//
  5 +// Created by 张旭 on 2017/3/15.
  6 +// Copyright © 2017年 cnlive. All rights reserved.
  7 +//
  8 +
  9 +#import "GiftAnimOperation.h"
  10 +#import "GiftModel.h"
  11 +#import "GiftComboView.h"
  12 +#import "NHCarViews.h"
  13 +#import "NHPlaneViews.h"
  14 +#import "GiftAnimationAction.h"
  15 +//#import "NHFighterView.h"
  16 +//#import "NHFighterView+animDelegagte.h"
  17 +
  18 +@interface GiftAnimOperation ()
  19 +{
  20 + BOOL _finished; //用于设置队列是否完成
  21 + BOOL _executing; //队列任务开始执行
  22 +}
  23 +
  24 +@property (nonatomic, strong)GiftComboView *giftComboView; //连击动画
  25 +@property (nonatomic, strong)NHCarViews *giftCarView; //跑车动画
  26 +//@property (nonatomic, strong)NHFighterView *giftFighterView; //歼灭机动画
  27 +@property (nonatomic, strong)NHPlaneViews *giftPlaneView; //客机动画
  28 +
  29 +@property (nonatomic, strong)GiftModel *model; //model
  30 +@property (nonatomic,strong) UIView *animContentView; //需要显示动画的view
  31 +@property (nonatomic, assign)NSInteger maxTop; //初始位置(需要根据显示设置最低位置在哪里)
  32 +@property (nonatomic ,strong) NSArray * _Nullable defaultTrajory;//默认轨迹数组
  33 +@property (nonatomic ,strong) NSMutableArray * _Nullable emptyTrajory;//当前空轨迹数组
  34 +
  35 +@end
  36 +
  37 +@implementation GiftAnimOperation
  38 +
  39 ++ (GiftAnimOperation *)addGiftAnimOperationWithGiftModel:(GiftModel *)model animContentView:(UIView *)animContentView maxTop:(NSInteger)maxTop{
  40 +
  41 + GiftAnimOperation *giftAnimOperation = [[GiftAnimOperation alloc]initWithGiftModel:model animContentView:animContentView maxTop:maxTop];
  42 + return giftAnimOperation;
  43 +}
  44 +
  45 +/**
  46 + 初始化
  47 +
  48 + @param model 礼物model
  49 + @param animContentView 需要把动画view添加到的view
  50 + @return obj
  51 + */
  52 +- (instancetype)initWithGiftModel:(GiftModel *)model animContentView:(UIView *)animContentView maxTop:(NSInteger)maxTop{
  53 + self = [super init];
  54 + if (self) {
  55 + self.model = model;
  56 + self.animContentView = animContentView;
  57 + self.maxTop = maxTop;
  58 + }
  59 + return self;
  60 +}
  61 +
  62 +/**
  63 + 开始方法(KVO控制队列任务状态)
  64 + */
  65 +- (void)start{
  66 + //这里动画队列任务不存在Cancelled状态所以不需要判断,直接开始执行
  67 + [self willChangeValueForKey:@"isExecuting"];
  68 + _executing = YES;
  69 + [self main];
  70 + [self didChangeValueForKey:@"isExecuting"];
  71 +}
  72 +
  73 +/**
  74 + 自定义Operation提供了start main接口。
  75 + */
  76 +- (void)main{
  77 +
  78 + switch (_model.giftStyle) {
  79 + case GiftStylePorsch:
  80 + [self porschAnimation];
  81 + break;
  82 +// case GiftStyleFighter:
  83 +// [self fighterAnimation];
  84 +// break;
  85 + case GiftStylePlane:
  86 + [self planeAnimation];
  87 + break;
  88 + case GiftStyleCombo:
  89 + [self comboViewAnimation];
  90 + break;
  91 + default:
  92 + break;
  93 + }
  94 +}
  95 +
  96 +- (void)porschAnimation
  97 +{
  98 + weakself
  99 + dispatch_async(dispatch_get_main_queue(), ^{
  100 + strongself
  101 +
  102 + [self.giftCarView addAnimationsMoveToPoint:CGPointMake(0, 100) endPoint:CGPointMake(self.animContentView.bounds.size.width +166, 500)];
  103 + [self.animContentView addSubview:self.giftCarView];
  104 +
  105 + [self.giftCarView startPorschAnimationWithCompletion:^{
  106 +
  107 + [self willChangeValueForKey:@"isFinished"];
  108 +
  109 + _finished = YES;
  110 +
  111 + [self didChangeValueForKey:@"isFinished"];
  112 + }];
  113 +
  114 + });
  115 +}
  116 +
  117 +//- (void)fighterAnimation
  118 +//{
  119 +// weakself
  120 +// dispatch_async(dispatch_get_main_queue(), ^{
  121 +// strongself
  122 +//
  123 +// [self.giftFighterView addAnimationsMoveToPoint:CGPointMake(SCREEN_WIDTH, 60) endPoint:CGPointMake( -500, 600)];
  124 +// [self.animContentView addSubview:self.giftFighterView];
  125 +// [self.giftFighterView startFighterAnimationWithCompletion:^{
  126 +// [self willChangeValueForKey:@"isFinished"];
  127 +//
  128 +// _finished = YES;
  129 +//
  130 +// [self didChangeValueForKey:@"isFinished"];
  131 +// }];
  132 +//
  133 +// });
  134 +//}
  135 +
  136 +- (void)planeAnimation
  137 +{
  138 + weakself
  139 + dispatch_async(dispatch_get_main_queue(), ^{
  140 + strongself
  141 +
  142 + [self.giftPlaneView addAnimationsMoveToPoint:CGPointMake(SCREEN_WIDTH, 100) endPoint:CGPointMake(-500, 410)];
  143 + [self.animContentView addSubview:self.giftPlaneView];
  144 + [self.giftPlaneView startPlaneAnimationWithCompletion:^{
  145 +
  146 + [self willChangeValueForKey:@"isFinished"];
  147 +
  148 + _finished = YES;
  149 +
  150 + [self didChangeValueForKey:@"isFinished"];
  151 + }];
  152 +
  153 + });
  154 +}
  155 +
  156 +static long currentCompleteIndex = 0;
  157 +/**
  158 + 连击动画
  159 + */
  160 +- (void)comboViewAnimation{
  161 +
  162 + __weak GiftAnimOperation *weakSelf = self;
  163 +// currentCompleteIndex ++;
  164 +
  165 +// if (self.emptyTrajory.count == 0)//index = 0
  166 +// {
  167 +// currentCompleteIndex = 0;
  168 +//
  169 +// }else if (self.emptyTrajory.count < 3)//从emptyArr取空的index并赋值 index
  170 +// {
  171 +//
  172 +//
  173 +// }else// = 3已满 index = 0
  174 +// {
  175 +// currentCompleteIndex = 0;
  176 +// }
  177 +// self.name = @"111";
  178 + dispatch_async(dispatch_get_main_queue(), ^{
  179 + [weakSelf.animContentView addSubview:weakSelf.giftComboView];
  180 +
  181 + weakSelf.giftComboView.top = [self.defaultTrajory[currentCompleteIndex] integerValue];
  182 +
  183 + NSLog(@"top:%zd,index%ld",[self.defaultTrajory[currentCompleteIndex] integerValue],currentCompleteIndex);
  184 + currentCompleteIndex ++;
  185 + if (currentCompleteIndex == 3)
  186 + {
  187 + currentCompleteIndex = 0;
  188 + }
  189 +// if ([self.name isEqualToString:@"李四_flower"]) {
  190 +//// currentCompleteIndex = 0;
  191 +// self.
  192 +// }
  193 + [weakSelf.giftComboView startComboAnimationWithCompletion:^{
  194 + NSLog(@"complet top:%zd,index%zd",[self.defaultTrajory[currentCompleteIndex] integerValue],currentCompleteIndex);
  195 + //empty存当前顺序
  196 +// [self.emptyTrajory replaceObjectAtIndex:<#(NSUInteger)#> withObject:<#(nonnull id)#>];
  197 + [weakSelf.giftComboView removeFromSuperview];
  198 +
  199 + [weakSelf willChangeValueForKey:@"isFinished"];
  200 +
  201 + _finished = YES;
  202 +
  203 + [weakSelf didChangeValueForKey:@"isFinished"];
  204 + }];
  205 + });
  206 +}
  207 +
  208 +/**
  209 + 连击动画
  210 +
  211 + @return 连击view
  212 + */
  213 +- (GiftComboView *)giftComboView{
  214 + if (_giftComboView == nil) {
  215 + _giftComboView = [GiftComboView comboView];
  216 + }
  217 + return _giftComboView;
  218 +}
  219 +
  220 +/**
  221 + 跑车动画
  222 +
  223 + @return 连击view
  224 + */
  225 +- (NHCarViews *)giftCarView{
  226 + if (_giftCarView == nil) {
  227 + _giftCarView = [NHCarViews loadCarViewWithPoint:CGPointZero];
  228 + //数组中放CGRect数据,CGRect的x和y分别作为控制点的x和y,CGRect的width和height作为结束点的x和y
  229 + //方法如下:数组内的每个元素代码一个控制点和结束点
  230 + NSMutableArray *pointArrs = [[NSMutableArray alloc] init];
  231 + CGFloat width = SCREEN_WIDTH / 2;
  232 + [pointArrs addObject:NSStringFromCGRect(CGRectMake(width, 300, width, 300))];
  233 + [pointArrs addObject:NSStringFromCGRect(CGRectMake(width, 300, width, 300))];
  234 + _giftCarView.curveControlAndEndPoints = pointArrs;
  235 + }
  236 + return _giftCarView;
  237 +}
  238 +
  239 +/**
  240 + 歼灭机动画
  241 +
  242 + @return 连击view
  243 + */
  244 +//- (NHFighterView *)giftFighterView{
  245 +// if (_giftFighterView == nil) {
  246 +// _giftFighterView = [NHFighterView loadFighterViewWithPoint:CGPointMake(10, 100)];
  247 +// }
  248 +// return _giftFighterView;
  249 +//}
  250 +
  251 +/**
  252 + 客机动画
  253 +
  254 + @return 连击view
  255 + */
  256 +- (NHPlaneViews *)giftPlaneView{
  257 + if (_giftPlaneView == nil) {
  258 + _giftPlaneView = [NHPlaneViews loadPlaneViewWithPoint:CGPointMake(SCREEN_WIDTH + 232, 0)];
  259 + }
  260 + return _giftPlaneView;
  261 +}
  262 +
  263 +- (NSArray *)defaultTrajory
  264 +{
  265 + if (!_defaultTrajory)
  266 + {
  267 + _defaultTrajory = [[NSArray alloc] initWithObjects:@200,@240,@280, nil];
  268 + }
  269 + return _defaultTrajory;
  270 +}
  271 +
  272 +- (NSMutableArray *)emptyTrajory
  273 +{
  274 + if (!_emptyTrajory)
  275 + {
  276 + _emptyTrajory = [[NSMutableArray alloc] init];
  277 + }
  278 + return _emptyTrajory;
  279 +}
  280 +
  281 +// 提示:To be deprecated; use and override 'asynchronous' below
  282 +//之前用的isConcurrent
  283 +/**
  284 + 覆写异步执行
  285 +
  286 + @return YES
  287 + */
  288 +- (BOOL)isAsynchronous{
  289 + return YES;
  290 +}
  291 +
  292 +/**
  293 + 覆写任务是否完成控制
  294 +
  295 + @return 完成状态 _finished
  296 + */
  297 +- (BOOL) isFinished{
  298 + return _finished;
  299 +}
  300 +
  301 +/**
  302 + 覆写任务是否完成开始执行
  303 +
  304 + @return 执行状态 _executing
  305 + */
  306 +- (BOOL) isExecuting{
  307 + return _executing;
  308 +}
  309 +
  310 +
  311 +
  312 +@end
... ...
LiveVideoCloud/LiveVideoCloud/Classes/Sections/InteractionSections/Gift/GiftAnimationAction.h 0 → 100644
  1 +//
  2 +// GiftAnimationAction.h
  3 +// LiveVideoCloud
  4 +//
  5 +// Created by 张旭 on 2017/3/15.
  6 +// Copyright © 2017年 cnlive. All rights reserved.
  7 +//
  8 +
  9 +#import <UIKit/UIKit.h>
  10 +
  11 +/**
  12 + 动画完成回调
  13 + */
  14 +typedef void(^giftAnimationCompletion)();
  15 +
  16 +@interface GiftAnimationAction : UIView<CAAnimationDelegate>{
  17 + giftAnimationCompletion _giftAnimationCompletion; //动画完成回调
  18 +}
  19 +
  20 +/**
  21 + 连击动画
  22 + */
  23 +- (void)startComboAnimationWithCompletion:(giftAnimationCompletion)Completion;
  24 +
  25 +/**
  26 + 跑车动画
  27 + */
  28 +- (void)startPorschAnimationWithCompletion:(giftAnimationCompletion)Completion;
  29 +
  30 +/**
  31 + 歼灭机动画
  32 + */
  33 +//- (void)startFighterAnimationWithCompletion:(giftAnimationCompletion)Completion;
  34 +
  35 +/**
  36 + 客机动画
  37 + */
  38 +- (void)startPlaneAnimationWithCompletion:(giftAnimationCompletion)Completion;
  39 +@end
... ...
LiveVideoCloud/LiveVideoCloud/Classes/Sections/InteractionSections/Gift/GiftAnimationAction.m 0 → 100644
  1 +//
  2 +// GiftAnimationAction.m
  3 +// LiveVideoCloud
  4 +//
  5 +// Created by 张旭 on 2017/3/15.
  6 +// Copyright © 2017年 cnlive. All rights reserved.
  7 +//
  8 +
  9 +#import "GiftAnimationAction.h"
  10 +
  11 +@implementation GiftAnimationAction
  12 +
  13 +/**
  14 + 连击横屏动画
  15 + */
  16 +- (void)startComboAnimationWithCompletion:(giftAnimationCompletion)Completion{
  17 + _giftAnimationCompletion = Completion;
  18 + NSLog(@"self.width:%f",self.width);
  19 + [self animationWithDuration:4
  20 + YValues:@[@(0 - self.width), @(115), @(110), @(110), @(0 - self.width)]
  21 + keyTimes:@[@0.0, @0.2, @0.3, @0.8, @1.0]
  22 + timingFunctions:@[
  23 + [CAMediaTimingFunction functionWithName: kCAMediaTimingFunctionEaseOut],
  24 + [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionDefault],
  25 + [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionDefault],
  26 + [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseIn]
  27 + ]
  28 + addView:self];
  29 +}
  30 +
  31 +/**
  32 + 位移动画具体实现
  33 +
  34 + @param duration 动画持续时间
  35 + @param YValues 动画帧数组
  36 + @param keyTimes 动画帧时间
  37 + @param timingFunctions 动画方式数组
  38 + @param addView 需要添加的view
  39 + */
  40 +- (void)animationWithDuration:(float)duration YValues:(NSArray *)YValues keyTimes:(NSArray *)keyTimes timingFunctions:(NSArray *)timingFunctions addView:(UIView *)addView{
  41 + CAKeyframeAnimation *rocketAnim = [CAKeyframeAnimation animation];
  42 + rocketAnim.keyPath = @"position.x";
  43 + rocketAnim.values = YValues;
  44 + rocketAnim.keyTimes = keyTimes;
  45 + rocketAnim.timingFunctions = timingFunctions;
  46 + rocketAnim.duration = duration;
  47 + rocketAnim.fillMode = kCAFillModeForwards;
  48 + rocketAnim.removedOnCompletion = NO;
  49 + rocketAnim.delegate = self;
  50 + [addView.layer addAnimation:rocketAnim forKey:@"positionY"];
  51 +}
  52 +
  53 +/**
  54 + 跑车动画
  55 + */
  56 +- (void)startPorschAnimationWithCompletion:(giftAnimationCompletion)Completion
  57 +{
  58 + _giftAnimationCompletion = Completion;
  59 +}
  60 +
  61 +/**
  62 + 歼灭机动画
  63 + */
  64 +//- (void)startFighterAnimationWithCompletion:(giftAnimationCompletion)Completion
  65 +//{
  66 +// _giftAnimationCompletion = Completion;
  67 +//}
  68 +
  69 +/**
  70 + 客机动画
  71 + */
  72 +- (void)startPlaneAnimationWithCompletion:(giftAnimationCompletion)Completion
  73 +{
  74 + _giftAnimationCompletion = Completion;
  75 +}
  76 +
  77 +/**
  78 + 动画回调代理,用于判断是否完成
  79 +
  80 + @param anim 动画对象
  81 + @param flag 是否完成标记
  82 + */
  83 +- (void)animationDidStop:(CAAnimation *)anim finished:(BOOL)flag{
  84 + _giftAnimationCompletion();
  85 +}
  86 +
  87 +
  88 +/*
  89 +// Only override drawRect: if you perform custom drawing.
  90 +// An empty implementation adversely affects performance during animation.
  91 +- (void)drawRect:(CGRect)rect {
  92 + // Drawing code
  93 +}
  94 +*/
  95 +
  96 +@end
... ...
LiveVideoCloud/LiveVideoCloud/Classes/Sections/InteractionSections/Gift/GiftComboView.h 0 → 100644
  1 +//
  2 +// GiftComboView.h
  3 +// LiveVideoCloud
  4 +//
  5 +// Created by 张旭 on 2017/3/15.
  6 +// Copyright © 2017年 cnlive. All rights reserved.
  7 +//
  8 +
  9 +#import "GiftAnimationAction.h"
  10 +
  11 +@class GiftModel;
  12 +@interface GiftComboView : GiftAnimationAction
  13 +
  14 +/**
  15 + 动画开始
  16 +
  17 + @param model 对应的动画解析model
  18 + @param animationCompletion 动画完成回调(用于控制队列)
  19 + */
  20 +- (void)startAnimationWithModel:(GiftModel *)model withAnimationCompletion: (giftAnimationCompletion)animationCompletion;
  21 +
  22 ++ (instancetype)comboView;
  23 +
  24 +@end
... ...
LiveVideoCloud/LiveVideoCloud/Classes/Sections/InteractionSections/Gift/GiftComboView.m 0 → 100644
  1 +//
  2 +// GiftComboView.m
  3 +// LiveVideoCloud
  4 +//
  5 +// Created by 张旭 on 2017/3/15.
  6 +// Copyright © 2017年 cnlive. All rights reserved.
  7 +//
  8 +
  9 +#import "GiftComboView.h"
  10 +#import "GiftModel.h"
  11 +
  12 +@interface GiftComboView (){
  13 + GiftModel *_model;//礼物model
  14 +}
  15 +
  16 +@end
  17 +
  18 +@implementation GiftComboView
  19 +
  20 +/**
  21 + 动画开始
  22 +
  23 + @param model 对应的动画解析model
  24 + @param animationCompletion 动画完成回调(用于控制队列)
  25 + */
  26 +- (void)startAnimationWithModel:(GiftModel *)model withAnimationCompletion: (giftAnimationCompletion)animationCompletion
  27 +{
  28 + _giftAnimationCompletion = animationCompletion;
  29 + _model = model;
  30 +
  31 + [self startComboAnimationWithCompletion:animationCompletion];
  32 +}
  33 +
  34 +
  35 +/**
  36 + 初始化连击View
  37 +
  38 + @return 初始化连击ComboView
  39 + */
  40 ++ (instancetype)comboView
  41 +{
  42 + GiftComboView *comboView = [[GiftComboView alloc] initWithFrame:CGRectMake(0, 0, 180, 30)];
  43 + comboView.backgroundColor = [UIColor blueColor];
  44 +
  45 + return comboView;
  46 +}
  47 +
  48 +/*
  49 +// Only override drawRect: if you perform custom drawing.
  50 +// An empty implementation adversely affects performance during animation.
  51 +- (void)drawRect:(CGRect)rect {
  52 + // Drawing code
  53 +}
  54 +*/
  55 +
  56 +@end
... ...
LiveVideoCloud/LiveVideoCloud/Classes/Sections/InteractionSections/Gift/GiftModel/GiftModel.h
... ... @@ -8,15 +8,28 @@
8 8  
9 9 #import "BaseModel.h"
10 10  
11   -typedef NS_ENUM(NSInteger, GiftModelType) {//礼物类型
12   - GiftModelTypeCommon = 1,//普通礼物
13   - GiftModelTypeSpecial //特殊(豪华)礼物
  11 +typedef NS_ENUM(NSInteger, GiftStyle) {//礼物类型
  12 + GiftStyleCombo = 1,//普通可连击礼物
  13 + GiftStylePorsch ,//豪华跑车礼物
  14 +// GiftStyleFighter ,//豪华歼灭机礼物
  15 + GiftStylePlane ,//豪华客机礼物
14 16 };
15 17  
16 18 @interface GiftModel : BaseModel
17 19  
18   -@property (nonatomic ,copy) NSString * _Nullable image;
19   -@property (nonatomic ) GiftModelType type;
20   -@property (nonatomic ,copy) NSString * _Nullable price;
  20 +@property (nonatomic ,copy ) NSString * _Nullable image;
  21 +@property (nonatomic ,copy ) NSString * _Nullable price;
  22 +
  23 +@property (nonatomic ) NSInteger index;//索引
  24 +@property (nonatomic ) GiftStyle giftStyle;//动画类型
  25 +@property (nonatomic, copy ) NSString * _Nullable giftname;//礼物名字
  26 +@property (nonatomic, strong) NSArray * _Nullable giftIconArray;//礼物图片数组
  27 +@property (nonatomic, copy ) NSString * _Nullable giftNum;//礼物数量
  28 +@property (nonatomic, copy ) NSString * _Nullable giftRusername;//接受礼物的人
  29 +@property (nonatomic, copy ) NSString * _Nullable giftRuserId;//接受礼物的人id
  30 +@property (nonatomic, copy ) NSString * _Nullable giftGusername;//送礼物的人
  31 +@property (nonatomic, copy ) NSString * _Nullable giftGuserId;//送礼物的id
  32 +
  33 +//@property (nonatomic, strong) NSString *_Nullable pushId;//跳转id
21 34  
22 35 @end
... ...
LiveVideoCloud/LiveVideoCloud/Classes/Sections/InteractionSections/Gift/GiftResource/NHCarViews.h
... ... @@ -7,8 +7,9 @@
7 7 //
8 8  
9 9 #import <UIKit/UIKit.h>
  10 +#import "GiftAnimationAction.h"
10 11  
11   -@interface NHCarViews : UIView
  12 +@interface NHCarViews : GiftAnimationAction
12 13 /**
13 14 * 需要几个控制点就设置几个:
14 15 * 数组内的每个元素代码一个控制点和结束点
... ...
LiveVideoCloud/LiveVideoCloud/Classes/Sections/InteractionSections/Gift/GiftResource/NHCarViews.m
... ... @@ -138,6 +138,7 @@
138 138 [self.layer removeAllAnimations];
139 139 [self removeFromSuperview];
140 140  
  141 + _giftAnimationCompletion(-1);
141 142 NSLog(@"删除动画");
142 143 // [self.animations removeObjectAtIndex:0];
143 144  
... ...
LiveVideoCloud/LiveVideoCloud/Classes/Sections/InteractionSections/Gift/GiftResource/NHFighterView+animDelegagte.h 0 → 100644
  1 +//
  2 +// NHFighterView+animDelegagte.h
  3 +// LiveVideoCloud
  4 +//
  5 +// Created by 张旭 on 2017/3/15.
  6 +// Copyright © 2017年 cnlive. All rights reserved.
  7 +//
  8 +
  9 +#import "NHFighterView.h"
  10 +
  11 +@interface NHFighterView (animDelegagte)
  12 +
  13 +@end
... ...
LiveVideoCloud/LiveVideoCloud/Classes/Sections/InteractionSections/Gift/GiftResource/NHFighterView+animDelegagte.m 0 → 100644
  1 +//
  2 +// NHFighterView+animDelegagte.m
  3 +// LiveVideoCloud
  4 +//
  5 +// Created by 张旭 on 2017/3/15.
  6 +// Copyright © 2017年 cnlive. All rights reserved.
  7 +//
  8 +
  9 +#import "NHFighterView+animDelegagte.h"
  10 +
  11 +@implementation NHFighterView (animDelegagte)
  12 +
  13 +- (void)animationDidStart:(CAAnimation *)anim
  14 +{
  15 + NSLog(@"did start");
  16 +}
  17 +
  18 +- (void)animationDidStop:(CAAnimation *)anim finished:(BOOL)flag
  19 +{
  20 + _giftAnimationCompletion(-1);
  21 + NSLog(@"did stop");
  22 +}
  23 +
  24 +@end
... ...
LiveVideoCloud/LiveVideoCloud/Classes/Sections/InteractionSections/Gift/GiftResource/NHFighterView.h
... ... @@ -7,8 +7,9 @@
7 7 //
8 8  
9 9 #import <UIKit/UIKit.h>
  10 +#import "GiftAnimationAction.h"
10 11  
11   -@interface NHFighterView : UIView
  12 +@interface NHFighterView :GiftAnimationAction
12 13  
13 14 /**
14 15 * 需要几个控制点就设置几个:
... ...
LiveVideoCloud/LiveVideoCloud/Classes/Sections/InteractionSections/Gift/GiftResource/NHPlaneViews.h
... ... @@ -7,8 +7,9 @@
7 7 //
8 8  
9 9 #import <UIKit/UIKit.h>
  10 +#import "GiftAnimationAction.h"
10 11  
11   -@interface NHPlaneViews : UIView
  12 +@interface NHPlaneViews : GiftAnimationAction
12 13  
13 14  
14 15 /**
... ...
LiveVideoCloud/LiveVideoCloud/Classes/Sections/InteractionSections/Gift/GiftResource/NHPlaneViews.m
... ... @@ -80,6 +80,7 @@
80 80 -(void)animationDidStop:(CAAnimation *)anim finished:(BOOL)flag{
81 81 [self.layer removeAllAnimations];
82 82 [self removeFromSuperview];
  83 + _giftAnimationCompletion(-1);
83 84 }
84 85  
85 86  
... ...
LiveVideoCloud/LiveVideoCloud/Classes/Sections/InteractionSections/Gift/GiftViews/GiftListView.h
... ... @@ -7,7 +7,9 @@
7 7 //
8 8  
9 9 #import "BaseView.h"
  10 +@class LiveBaseView;
10 11  
11 12 @interface GiftListView : BaseView
12 13  
  14 +- (instancetype _Nonnull)initWithFrame:(CGRect)frame liveBaseView:(LiveBaseView *_Nullable)liveBaseView;
13 15 @end
... ...
LiveVideoCloud/LiveVideoCloud/Classes/Sections/InteractionSections/Gift/GiftViews/GiftListView.m
... ... @@ -8,6 +8,8 @@
8 8  
9 9 #import "GiftListView.h"
10 10 #import "GiftModel.h"
  11 +#import "LiveBaseView.h"
  12 +#import "AnimQueueManager.h"
11 13  
12 14 #define MAX_LINE_COUNT 4
13 15 #define MAX_ROW_COUNT 2
... ... @@ -15,24 +17,29 @@
15 17 @interface GiftListView ()
16 18  
17 19 @property (nonatomic ,strong) NSArray <GiftModel *>* _Nullable giftArray;
  20 +@property (nonatomic ,weak) LiveBaseView * _Nullable liveBaseView;
  21 +@property (nonatomic, strong) AnimQueueManager *animQueueManager;
  22 +@property (nonatomic ,strong) GiftModel * _Nullable model;
18 23  
19 24 @end
20 25  
21 26 @implementation GiftListView
22 27  
23   -- (instancetype)initWithFrame:(CGRect)frame
  28 +- (instancetype)initWithFrame:(CGRect)frame liveBaseView:(LiveBaseView *_Nullable)liveBaseView
24 29 {
25 30 if (self = [super initWithFrame:frame]) {
  31 + self.liveBaseView = liveBaseView;
  32 + self.animQueueManager = [AnimQueueManager sharedAnimQueueManager];
  33 + self.animQueueManager.maxTop = 200;
26 34  
27   -
28   - UIScrollView *scrollView = [[UIScrollView alloc] initWithFrame:self.bounds];
29   - scrollView.contentSize = CGSizeMake(self.width *(self.giftArray.count/(MAX_ROW_COUNT*MAX_LINE_COUNT) + 1), self.height);
  35 + UIScrollView *scrollView = [[UIScrollView alloc] initWithFrame:CGRectMake(0, 0, self.width, self.height - 30)];
  36 + scrollView.contentSize = CGSizeMake(self.width *(self.giftArray.count/(MAX_ROW_COUNT*MAX_LINE_COUNT) + 1), self.height - 30);
30 37 scrollView.pagingEnabled = YES;
31 38 scrollView.bounces = NO;
32 39 scrollView.showsVerticalScrollIndicator = NO;
33 40 scrollView.showsHorizontalScrollIndicator = NO;
34   - scrollView.backgroundColor = [UIColor blueColor];
35 41 [self addSubview:scrollView];
  42 + scrollView.backgroundColor = ZXRandomColor;
36 43  
37 44 int line = 0;
38 45 int row = 0;
... ... @@ -50,12 +57,11 @@
50 57 }
51 58 row = i % MAX_LINE_COUNT;
52 59 CGFloat giftWidth = self.width / MAX_LINE_COUNT * 1.0;
53   - CGFloat giftHeight = self.height / MAX_ROW_COUNT * 1.0;
  60 + CGFloat giftHeight = (self.height - 30) / MAX_ROW_COUNT * 1.0;
54 61 giftX = row * giftWidth + page * scrollView.width;
55 62 giftY = line * giftHeight;
56 63  
57 64 UIView *giftView = [self giftViewWithFrame:CGRectMake(giftX, giftY, giftWidth, giftHeight) model:self.giftArray[i]];
58   - giftView.backgroundColor = ZXRandomColor;
59 65  
60 66 UIImageView *picImg = [[UIImageView alloc] initWithImage:[UIImage imageNamed:self.giftArray[i].image]];
61 67 picImg.centerX = giftView.width * 0.5;
... ... @@ -63,6 +69,10 @@
63 69 [giftView addSubview:picImg];
64 70  
65 71 [scrollView addSubview:giftView];
  72 +
  73 + UITapGestureRecognizer *gesture = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(gestureClick:)];
  74 + giftView.tag = i + 10;
  75 + [giftView addGestureRecognizer:gesture];
66 76 }
67 77 }
68 78 return self;
... ... @@ -70,40 +80,84 @@
70 80  
71 81 - (UIView *)giftViewWithFrame:(CGRect)frame model:(GiftModel *)model
72 82 {
  83 + _model = model;
73 84 UIView *giftView = [[UIView alloc] initWithFrame:frame];
74   - switch (model.type) {
75   - case GiftModelTypeCommon:
76   - {
77   - UIImageView *imageView = [[UIImageView alloc] initWithFrame:CGRectMake(giftView.width - 17, 3, 15, 15)];
78   - imageView.backgroundColor = ZXRandomColor;
79   - [giftView addSubview:imageView];
80   - }
81   - break;
82   - case GiftModelTypeSpecial:
83   - {
84   -
85   - }
86   - break;
87   - default:
88   - break;
  85 + if (model.giftStyle == GiftStyleCombo)
  86 + {
  87 + UIImageView *imageView = [[UIImageView alloc] initWithFrame:CGRectMake(giftView.width - 17, 3, 15, 15)];
  88 + imageView.backgroundColor = ZXRandomColor;
  89 + [giftView addSubview:imageView];
  90 + }else
  91 + {
  92 +
89 93 }
  94 + UILabel *priceLbl = [[UILabel alloc] initWithFrame:CGRectMake(0, giftView.height - 15, 40, 14)];
  95 + priceLbl.font = [UIFont systemFontOfSize:kDetailContentFont];
  96 + priceLbl.textColor = [UIColor greenColor];
  97 + priceLbl.text = model.price;
  98 + priceLbl.width = [priceLbl labelSize].width;
  99 + priceLbl.height = [priceLbl labelSize].height;
  100 + priceLbl.centerX = giftView.width * 0.5 - 4;
  101 + [giftView addSubview:priceLbl];
  102 +
  103 + UIImageView *image = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"littleHeart2"]];
  104 + image.left = priceLbl.right + 3;
  105 + image.centerY = priceLbl.centerY;
  106 + [giftView addSubview:image];
90 107  
91   - UIButton *coin = [[UIButton alloc] initWithFrame:CGRectMake(0, giftView.height - 13, 15, 10)];
92   - coin.centerX = giftView.width * 0.5;
93   - coin.backgroundColor = ZXRandomColor;
94   - [giftView addSubview:coin];
95 108 return giftView;
96 109 }
97 110  
  111 +#pragma mark - 选择礼物点击
  112 +- (void)gestureClick:(UITapGestureRecognizer *)gesture
  113 +{
  114 + NSInteger tag = gesture.view.tag - 10;
  115 + NSLog(@"%zd",tag);
  116 + //右上角添加✔️,再次点击去掉✔️
  117 + [self.animQueueManager addAnimationWithModel:self.giftArray[tag] animContentView:self.liveBaseView];
  118 +}
  119 +
  120 +#pragma mark - getter
  121 +
98 122 - (NSArray *)giftArray
99 123 {
100 124 if (!_giftArray)
101 125 {
102   - GiftModel *model = [[GiftModel alloc] init];
103   - model.image = @"love";
104   - model.type = GiftModelTypeCommon;
105   - model.price = @"3";
106   - _giftArray = [[NSArray alloc] initWithObjects:model,model,model,model,model,model,model,model,model,model, nil];
  126 + NSArray *images = [NSArray arrayWithObjects:@"love",@"love",@"love",@"love",@"love",@"love",@"love",@"love",@"love",@"love",nil];
  127 + NSArray *types = [NSArray arrayWithObjects:@2,@3,@1,@1,@1,@1,@1,@1,@1,@1, nil];
  128 + NSArray *prices = [NSArray arrayWithObjects:@"300000000",@"3000",@"300000",@"30",@"3",@"3",@"1",@"3",@"1",@"3", nil];
  129 +
  130 + NSMutableArray *tempArr = [NSMutableArray array];
  131 + for (int i = 0; i < images.count; i ++) {
  132 + GiftModel *model = [GiftModel new];
  133 + model.giftname = @"鲜花";
  134 + model.giftIconArray = @[[UIImage imageNamed:@"love"]];
  135 + model.giftNum = @"5";
  136 + model.giftRusername = @"啊啊啊啊啊啊啊啊啊啊啊啊";
  137 + model.giftRuserId = @"10000";
  138 + model.giftGusername = @"按时大多数阿萨德 爱傻傻的爱的";
  139 + model.giftGuserId = @"20000";
  140 + model.image = images[i];
  141 + int type = [types[i] intValue];
  142 + if (type == 1) {
  143 + model.giftStyle = GiftStyleCombo;
  144 + }else if (type == 2)
  145 + {
  146 + model.giftStyle = GiftStylePorsch;
  147 + }
  148 +// else if (type == 3)
  149 +// {
  150 +// model.giftStyle = GiftStyleFighter;
  151 +// }
  152 + else if (type == 3)
  153 + {
  154 + model.giftStyle = GiftStylePlane;
  155 + }
  156 +
  157 + model.price = prices[i];
  158 + [tempArr addObject:model];
  159 + }
  160 + _giftArray = [[NSArray alloc] initWithArray:tempArr];
107 161 }
108 162 return _giftArray;
109 163 }
... ...
LiveVideoCloud/LiveVideoCloud/Classes/Sections/InteractionSections/Gift/LVCGiftManager.h deleted 100644 → 0
1   -//
2   -// LVCGiftManager.h
3   -// LiveVideoCloud
4   -//
5   -// Created by 张旭 on 2017/3/13.
6   -// Copyright © 2017年 cnlive. All rights reserved.
7   -//
8   -
9   -#import <Foundation/Foundation.h>
10   -
11   -typedef NS_ENUM(NSInteger, GiftType) {//礼物类型
12   - GiftTypePorsch = 1,//跑车
13   - GiftTypeFighter ,//歼灭机
14   - GiftTypePlane ,//客机
15   -};
16   -
17   -@interface LVCGiftManager : NSObject
18   -
19   -+ (void)giftType:(GiftType)giftType toView:(UIView *_Nonnull)toView;
20   -
21   -@end
22   -
LiveVideoCloud/LiveVideoCloud/Classes/Sections/InteractionSections/Gift/LVCGiftManager.m deleted 100644 → 0
1   -//
2   -// LVCGiftManager.m
3   -// LiveVideoCloud
4   -//
5   -// Created by 张旭 on 2017/3/13.
6   -// Copyright © 2017年 cnlive. All rights reserved.
7   -//
8   -
9   -#import "LVCGiftManager.h"
10   -#import "NHCarViews.h"
11   -#import "NHFighterView.h"
12   -#import "NHPlaneViews.h"
13   -
14   -@implementation LVCGiftManager
15   -
16   -+ (void)giftType:(GiftType)giftType toView:(UIView *_Nonnull)toView
17   -{
18   -
19   - switch (giftType) {
20   - case GiftTypePorsch:
21   - {
22   - NHCarViews *car = [NHCarViews loadCarViewWithPoint:CGPointZero];
23   - //数组中放CGRect数据,CGRect的x和y分别作为控制点的x和y,CGRect的width和height作为结束点的x和y
24   - //方法如下:数组内的每个元素代码一个控制点和结束点
25   - NSMutableArray *pointArrs = [[NSMutableArray alloc] init];
26   - CGFloat width = SCREEN_WIDTH / 2;
27   - [pointArrs addObject:NSStringFromCGRect(CGRectMake(width, 300, width, 300))];
28   - [pointArrs addObject:NSStringFromCGRect(CGRectMake(width, 300, width, 300))];
29   - car.curveControlAndEndPoints = pointArrs;
30   - [car addAnimationsMoveToPoint:CGPointMake(0, 100) endPoint:CGPointMake(toView.bounds.size.width +166, 500)];
31   - [toView addSubview:car];
32   - }
33   - break;
34   - case GiftTypeFighter:
35   - {
36   - NHFighterView *fighter = [NHFighterView loadFighterViewWithPoint:CGPointMake(10, 100)];
37   - [fighter addAnimationsMoveToPoint:CGPointMake(SCREEN_WIDTH, 60) endPoint:CGPointMake( -500, 600)];
38   - [toView addSubview:fighter];
39   - }
40   - break;
41   - case GiftTypePlane:
42   - {
43   - NHPlaneViews *plane = [NHPlaneViews loadPlaneViewWithPoint:CGPointMake(SCREEN_WIDTH + 232, 0)];
44   -// NSMutableArray *pointArrs = [[NSMutableArray alloc] init];
45   -// [pointArrs addObject:NSStringFromCGRect(CGRectMake(290, 250, 290, 250))];
46   -// [pointArrs addObject:NSStringFromCGRect(CGRectMake(290, 250, 290, 250))];
47   -// plane.curveControlAndEndPoints = pointArrs;
48   - [plane addAnimationsMoveToPoint:CGPointMake(SCREEN_WIDTH, 100) endPoint:CGPointMake(-500, 410)];
49   - [toView addSubview:plane];
50   - }
51   - break;
52   -
53   - default:
54   - break;
55   - }
56   -
57   -
58   - }
59   -
60   -@end
LiveVideoCloud/LiveVideoCloud/Classes/Sections/InteractionSections/LVCInteractionController.m
... ... @@ -33,7 +33,8 @@
33 33 if (!_liveBaseView)
34 34 {
35 35 _liveBaseView = [[LiveBaseView alloc] initWithFrame:SCREEN_RECT];
36   - _liveBaseView.backgroundColor = [UIColor greenColor];
  36 + _liveBaseView.viewController = self;
  37 + _liveBaseView.backgroundColor = [UIColor clearColor];
37 38 }
38 39 return _liveBaseView;
39 40 }
... ...
LiveVideoCloud/LiveVideoCloud/Classes/Sections/InteractionSections/LiveBaseView.h
... ... @@ -10,4 +10,6 @@
10 10  
11 11 @interface LiveBaseView : BaseView
12 12  
  13 +@property (nonatomic ,strong) UIViewController * _Nullable viewController;
  14 +
13 15 @end
... ...
LiveVideoCloud/LiveVideoCloud/Classes/Sections/InteractionSections/LiveBaseView.m
... ... @@ -8,10 +8,9 @@
8 8 //
9 9  
10 10 #import "LiveBaseView.h"
11   -#import "LVCGiftManager.h"
12 11 #import "BottomToolView.h"
13 12 #import "GiftListView.h"
14   -
  13 +#import "GiftModel.h"
15 14 @interface LiveBaseView ()<bottomBtnDeledate>
16 15  
17 16 @property (nonatomic ,strong) UIScrollView * _Nullable scrollView;
... ... @@ -19,10 +18,6 @@
19 18 @property (nonatomic ,strong) UIButton * _Nullable closeBtn;
20 19 @property (nonatomic ,strong) UIView * _Nullable currentPopView;
21 20  
22   -@property (nonatomic ,strong) UIButton * _Nullable porschBtn;
23   -@property (nonatomic ,strong) UIButton * _Nullable fightBtn;
24   -@property (nonatomic ,strong) UIButton * _Nullable planeBtn;
25   -
26 21 @end
27 22  
28 23 @implementation LiveBaseView
... ... @@ -34,11 +29,7 @@
34 29 [self addSubview:self.scrollView];
35 30 [self.scrollView addSubview:self.bottomToolView];
36 31 [self addSubview:self.closeBtn];
37   - [self addGestureRecognizer:[[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapGestureClick)]];
38   -
39   -// [self addSubview:self.porschBtn];
40   -// [self addSubview:self.fightBtn];
41   -// [self addSubview:self.planeBtn];
  32 + [self addGestureRecognizer:[[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapGestureClick:)]];
42 33 }
43 34 return self;
44 35 }
... ... @@ -60,14 +51,11 @@
60 51 break;
61 52 case BtnClickTypeGift:
62 53 {
63   - GiftListView *giftListView = [[GiftListView alloc] initWithFrame:CGRectMake(0, SCREEN_HEIGHT - 200, SCREEN_WIDTH, 200)];
64   - giftListView.backgroundColor = [UIColor redColor];
  54 + GiftListView *giftListView = [[GiftListView alloc] initWithFrame:CGRectMake(0, SCREEN_HEIGHT - 230, SCREEN_WIDTH, 230) liveBaseView:self];
  55 + giftListView.backgroundColor = [UIColor lightGrayColor];
65 56 [self addSubview:giftListView];
66 57 self.currentPopView = giftListView;
67   -
68   -
69   -
70   -
  58 +
71 59 }
72 60 break;
73 61 default:
... ... @@ -93,30 +81,20 @@
93 81 }
94 82  
95 83 #pragma mark - buttonClick
96   -- (void)tapGestureClick
  84 +- (void)tapGestureClick:(UITapGestureRecognizer *)gesture
97 85 {
98 86 [self clearCurrentPopView];
99 87 }
100 88  
101   -
102   -- (void)porschAction
103   -{
104   - [LVCGiftManager giftType:GiftTypePorsch toView:self];
105   -}
106   -
107   -- (void)fightAction
108   -{
109   - [LVCGiftManager giftType:GiftTypeFighter toView:self];
110   -}
111   -
112   -- (void)planeAction
  89 +- (void)closeAction
113 90 {
114   - [LVCGiftManager giftType:GiftTypePlane toView:self];
  91 + [self.viewController.navigationController popViewControllerAnimated:YES];
115 92 }
116 93  
117   -- (void)closeAction
  94 +#pragma mark - setter
  95 +-(void)setViewController:(UIViewController *)viewController
118 96 {
119   -
  97 + _viewController = viewController;
120 98 }
121 99  
122 100 #pragma mark - getter
... ... @@ -162,48 +140,6 @@
162 140 return _closeBtn;
163 141 }
164 142  
165   -- (UIButton *)porschBtn
166   -{
167   - if (!_porschBtn)
168   - {
169   - UIButton *porschBtn = [UIButton buttonWithType:UIButtonTypeCustom];
170   - porschBtn.frame = CGRectMake(SCREEN_WIDTH - 80, 400, 80, 30);
171   - [porschBtn setTitle:@"保时捷" forState:UIControlStateNormal];
172   - [porschBtn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
173   - [porschBtn addTarget:self action:@selector(porschAction) forControlEvents:UIControlEventTouchUpInside];
174   - _porschBtn = porschBtn;
175   - }
176   - return _porschBtn;
177   -}
178   -
179   -- (UIButton *)fightBtn
180   -{
181   - if (!_fightBtn)
182   - {
183   - UIButton *fightBtn = [UIButton buttonWithType:UIButtonTypeCustom];
184   - fightBtn.frame = CGRectMake(SCREEN_WIDTH - 80, 450, 80, 30);
185   - [fightBtn setTitle:@"歼灭机" forState:UIControlStateNormal];
186   - [fightBtn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
187   - [fightBtn addTarget:self action:@selector(fightAction) forControlEvents:UIControlEventTouchUpInside];
188   - _fightBtn = fightBtn;
189   - }
190   - return _fightBtn;
191   -}
192   -
193   -- (UIButton *)planeBtn
194   -{
195   - if (!_planeBtn)
196   - {
197   - UIButton *planeBtn = [UIButton buttonWithType:UIButtonTypeCustom];
198   - planeBtn.frame = CGRectMake(SCREEN_WIDTH - 80, 500, 80, 30);
199   - [planeBtn setTitle:@"客机" forState:UIControlStateNormal];
200   - [planeBtn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
201   - [planeBtn addTarget:self action:@selector(planeAction) forControlEvents:UIControlEventTouchUpInside];
202   - _planeBtn = planeBtn;
203   - }
204   - return _planeBtn;
205   -}
206   -
207 143 /*
208 144 // Only override drawRect: if you perform custom drawing.
209 145 // An empty implementation adversely affects performance during animation.
... ...
LiveVideoCloud/LiveVideoCloud/animation.xcassets/Interaction/littleHeart.imageset/Contents.json 0 → 100644
  1 +{
  2 + "images" : [
  3 + {
  4 + "idiom" : "universal",
  5 + "filename" : "littleHeart.png",
  6 + "scale" : "1x"
  7 + },
  8 + {
  9 + "idiom" : "universal",
  10 + "scale" : "2x"
  11 + },
  12 + {
  13 + "idiom" : "universal",
  14 + "scale" : "3x"
  15 + }
  16 + ],
  17 + "info" : {
  18 + "version" : 1,
  19 + "author" : "xcode"
  20 + }
  21 +}
0 22 \ No newline at end of file
... ...
LiveVideoCloud/LiveVideoCloud/animation.xcassets/Interaction/littleHeart.imageset/littleHeart.png 0 → 100644

1009 Bytes

LiveVideoCloud/LiveVideoCloud/animation.xcassets/Interaction/littleHeart1.imageset/Contents.json 0 → 100644
  1 +{
  2 + "images" : [
  3 + {
  4 + "idiom" : "universal",
  5 + "filename" : "littleHeart1.png",
  6 + "scale" : "1x"
  7 + },
  8 + {
  9 + "idiom" : "universal",
  10 + "scale" : "2x"
  11 + },
  12 + {
  13 + "idiom" : "universal",
  14 + "scale" : "3x"
  15 + }
  16 + ],
  17 + "info" : {
  18 + "version" : 1,
  19 + "author" : "xcode"
  20 + }
  21 +}
0 22 \ No newline at end of file
... ...
LiveVideoCloud/LiveVideoCloud/animation.xcassets/Interaction/littleHeart1.imageset/littleHeart1.png 0 → 100644

680 Bytes

LiveVideoCloud/LiveVideoCloud/animation.xcassets/Interaction/littleHeart2.imageset/Contents.json 0 → 100644
  1 +{
  2 + "images" : [
  3 + {
  4 + "idiom" : "universal",
  5 + "filename" : "littleHeart2.png",
  6 + "scale" : "1x"
  7 + },
  8 + {
  9 + "idiom" : "universal",
  10 + "scale" : "2x"
  11 + },
  12 + {
  13 + "idiom" : "universal",
  14 + "scale" : "3x"
  15 + }
  16 + ],
  17 + "info" : {
  18 + "version" : 1,
  19 + "author" : "xcode"
  20 + }
  21 +}
0 22 \ No newline at end of file
... ...
LiveVideoCloud/LiveVideoCloud/animation.xcassets/Interaction/littleHeart2.imageset/littleHeart2.png 0 → 100644

787 Bytes