修改了糖果树开出的礼物大于2级才显示以及动画的问题
This commit is contained in:
@@ -457,7 +457,6 @@
|
|||||||
E8DACCFE27673F870052092C /* GiftValueInfoModel.m in Sources */ = {isa = PBXBuildFile; fileRef = E8DACCFD27673F870052092C /* GiftValueInfoModel.m */; };
|
E8DACCFE27673F870052092C /* GiftValueInfoModel.m in Sources */ = {isa = PBXBuildFile; fileRef = E8DACCFD27673F870052092C /* GiftValueInfoModel.m */; };
|
||||||
E8DEC98B27637EA50078CB70 /* candyTree_open.svga in Resources */ = {isa = PBXBuildFile; fileRef = E8DEC98927637EA50078CB70 /* candyTree_open.svga */; };
|
E8DEC98B27637EA50078CB70 /* candyTree_open.svga in Resources */ = {isa = PBXBuildFile; fileRef = E8DEC98927637EA50078CB70 /* candyTree_open.svga */; };
|
||||||
E8DEC98C27637EA50078CB70 /* candyTree_transform.svga in Resources */ = {isa = PBXBuildFile; fileRef = E8DEC98A27637EA50078CB70 /* candyTree_transform.svga */; };
|
E8DEC98C27637EA50078CB70 /* candyTree_transform.svga in Resources */ = {isa = PBXBuildFile; fileRef = E8DEC98A27637EA50078CB70 /* candyTree_transform.svga */; };
|
||||||
E8DEC98F27643EB30078CB70 /* XPCandyTreeAnimationManager.m in Sources */ = {isa = PBXBuildFile; fileRef = E8DEC98E27643EB30078CB70 /* XPCandyTreeAnimationManager.m */; };
|
|
||||||
E8DEC992276441AA0078CB70 /* XPCandyTreeAnimationModel.m in Sources */ = {isa = PBXBuildFile; fileRef = E8DEC991276441AA0078CB70 /* XPCandyTreeAnimationModel.m */; };
|
E8DEC992276441AA0078CB70 /* XPCandyTreeAnimationModel.m in Sources */ = {isa = PBXBuildFile; fileRef = E8DEC991276441AA0078CB70 /* XPCandyTreeAnimationModel.m */; };
|
||||||
E8DEC99527648FA50078CB70 /* ClientConfig.m in Sources */ = {isa = PBXBuildFile; fileRef = E8DEC99427648FA50078CB70 /* ClientConfig.m */; };
|
E8DEC99527648FA50078CB70 /* ClientConfig.m in Sources */ = {isa = PBXBuildFile; fileRef = E8DEC99427648FA50078CB70 /* ClientConfig.m */; };
|
||||||
E8DEC99E2764A5B60078CB70 /* XPRoomMoreMenuViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = E8DEC99D2764A5B60078CB70 /* XPRoomMoreMenuViewController.m */; };
|
E8DEC99E2764A5B60078CB70 /* XPRoomMoreMenuViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = E8DEC99D2764A5B60078CB70 /* XPRoomMoreMenuViewController.m */; };
|
||||||
@@ -1405,8 +1404,6 @@
|
|||||||
E8DACCFD27673F870052092C /* GiftValueInfoModel.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = GiftValueInfoModel.m; sourceTree = "<group>"; };
|
E8DACCFD27673F870052092C /* GiftValueInfoModel.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = GiftValueInfoModel.m; sourceTree = "<group>"; };
|
||||||
E8DEC98927637EA50078CB70 /* candyTree_open.svga */ = {isa = PBXFileReference; lastKnownFileType = file; path = candyTree_open.svga; sourceTree = "<group>"; };
|
E8DEC98927637EA50078CB70 /* candyTree_open.svga */ = {isa = PBXFileReference; lastKnownFileType = file; path = candyTree_open.svga; sourceTree = "<group>"; };
|
||||||
E8DEC98A27637EA50078CB70 /* candyTree_transform.svga */ = {isa = PBXFileReference; lastKnownFileType = file; path = candyTree_transform.svga; sourceTree = "<group>"; };
|
E8DEC98A27637EA50078CB70 /* candyTree_transform.svga */ = {isa = PBXFileReference; lastKnownFileType = file; path = candyTree_transform.svga; sourceTree = "<group>"; };
|
||||||
E8DEC98D27643EB30078CB70 /* XPCandyTreeAnimationManager.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = XPCandyTreeAnimationManager.h; sourceTree = "<group>"; };
|
|
||||||
E8DEC98E27643EB30078CB70 /* XPCandyTreeAnimationManager.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = XPCandyTreeAnimationManager.m; sourceTree = "<group>"; };
|
|
||||||
E8DEC990276441AA0078CB70 /* XPCandyTreeAnimationModel.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = XPCandyTreeAnimationModel.h; sourceTree = "<group>"; };
|
E8DEC990276441AA0078CB70 /* XPCandyTreeAnimationModel.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = XPCandyTreeAnimationModel.h; sourceTree = "<group>"; };
|
||||||
E8DEC991276441AA0078CB70 /* XPCandyTreeAnimationModel.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = XPCandyTreeAnimationModel.m; sourceTree = "<group>"; };
|
E8DEC991276441AA0078CB70 /* XPCandyTreeAnimationModel.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = XPCandyTreeAnimationModel.m; sourceTree = "<group>"; };
|
||||||
E8DEC99327648FA50078CB70 /* ClientConfig.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ClientConfig.h; sourceTree = "<group>"; };
|
E8DEC99327648FA50078CB70 /* ClientConfig.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ClientConfig.h; sourceTree = "<group>"; };
|
||||||
@@ -3443,8 +3440,6 @@
|
|||||||
E8A03DEB276301EF0098D9EA /* XPCandyTreeRankView.m */,
|
E8A03DEB276301EF0098D9EA /* XPCandyTreeRankView.m */,
|
||||||
E8A03DFA276350A60098D9EA /* XPCandyTreeGiftView.h */,
|
E8A03DFA276350A60098D9EA /* XPCandyTreeGiftView.h */,
|
||||||
E8A03DFB276350A60098D9EA /* XPCandyTreeGiftView.m */,
|
E8A03DFB276350A60098D9EA /* XPCandyTreeGiftView.m */,
|
||||||
E8DEC98D27643EB30078CB70 /* XPCandyTreeAnimationManager.h */,
|
|
||||||
E8DEC98E27643EB30078CB70 /* XPCandyTreeAnimationManager.m */,
|
|
||||||
);
|
);
|
||||||
path = View;
|
path = View;
|
||||||
sourceTree = "<group>";
|
sourceTree = "<group>";
|
||||||
@@ -4566,7 +4561,6 @@
|
|||||||
E811FFF72742367B00918544 /* XPGiftEmptyCollectionViewCell.m in Sources */,
|
E811FFF72742367B00918544 /* XPGiftEmptyCollectionViewCell.m in Sources */,
|
||||||
189DD67E26E1FD8900AB55B1 /* UIImage+Utils.m in Sources */,
|
189DD67E26E1FD8900AB55B1 /* UIImage+Utils.m in Sources */,
|
||||||
E824545626F5E51900BE8163 /* XPMineVerifIdentityViewController.m in Sources */,
|
E824545626F5E51900BE8163 /* XPMineVerifIdentityViewController.m in Sources */,
|
||||||
E8DEC98F27643EB30078CB70 /* XPCandyTreeAnimationManager.m in Sources */,
|
|
||||||
E82D5C73276AE94800858D6D /* CarModel.m in Sources */,
|
E82D5C73276AE94800858D6D /* CarModel.m in Sources */,
|
||||||
186A534726FC6ED900D67B2C /* TTAlertConfig.m in Sources */,
|
186A534726FC6ED900D67B2C /* TTAlertConfig.m in Sources */,
|
||||||
18F403EE2758CF2F00A6C548 /* MessageContentImage.m in Sources */,
|
18F403EE2758CF2F00A6C548 /* MessageContentImage.m in Sources */,
|
||||||
|
@@ -1,28 +0,0 @@
|
|||||||
//
|
|
||||||
// XPCandyTreeAnimationManager.h
|
|
||||||
// xplan-ios
|
|
||||||
//
|
|
||||||
// Created by 冯硕 on 2021/12/11.
|
|
||||||
//
|
|
||||||
/**
|
|
||||||
开糖果的动画
|
|
||||||
1. 只有一个的时候 alpha 0-1 的动画 然后 alpha 1-0
|
|
||||||
2. 当第一个还没结束的时候第二个来了 第一个执行平移动画 向上移动 第二个做alpha 0-1 如果没有第三个的话 第一个 先执行 aplha 1-0 完成之后 第二个执行alpha 1-0
|
|
||||||
3. 第三个 同上面的逻辑
|
|
||||||
4. 第四个来的时候 第一个消失 第二个移动到第一个位置 第三个移动到第二个的位置 第四个执行alpha 0-1
|
|
||||||
*/
|
|
||||||
|
|
||||||
#import <Foundation/Foundation.h>
|
|
||||||
|
|
||||||
NS_ASSUME_NONNULL_BEGIN
|
|
||||||
@class CandyTreeGiftInfoModel;
|
|
||||||
@interface XPCandyTreeAnimationManager : NSObject
|
|
||||||
|
|
||||||
///动画需要在什么地方执行
|
|
||||||
@property (nonatomic,strong) UIView * containerView;
|
|
||||||
|
|
||||||
- (void)receiveCandyTreeGift:(CandyTreeGiftInfoModel *)giftInfo;
|
|
||||||
|
|
||||||
@end
|
|
||||||
|
|
||||||
NS_ASSUME_NONNULL_END
|
|
@@ -1,291 +0,0 @@
|
|||||||
//
|
|
||||||
// XPCandyTreeAnimationManager.m
|
|
||||||
// xplan-ios
|
|
||||||
//
|
|
||||||
// Created by 冯硕 on 2021/12/11.
|
|
||||||
//
|
|
||||||
|
|
||||||
#import "XPCandyTreeAnimationManager.h"
|
|
||||||
///Third
|
|
||||||
#import <Masonry/Masonry.h>
|
|
||||||
#import "XPCandyTreeGiftView.h"
|
|
||||||
#import "XPCandyTreeAnimationModel.h"
|
|
||||||
#import "CandyTreeResultModel.h"
|
|
||||||
|
|
||||||
#define KitemHeight 20
|
|
||||||
#define KitemMargin 5
|
|
||||||
|
|
||||||
@interface XPCandyTreeAnimationManager ()
|
|
||||||
///存放所有需要显示的礼物的
|
|
||||||
@property (strong, nonatomic) NSMutableArray<XPCandyTreeGiftView *>*giftAnimateQueue;
|
|
||||||
///可见池
|
|
||||||
@property (strong,nonatomic)NSMutableArray<XPCandyTreeGiftView *> * giftVisiablePool;
|
|
||||||
///Timer
|
|
||||||
@property (nonatomic ,strong)dispatch_source_t timer;
|
|
||||||
///是否正在动画
|
|
||||||
@property (nonatomic,assign) BOOL isAnimationing;
|
|
||||||
///view的中心
|
|
||||||
@property (nonatomic,assign) CGFloat offsetY;
|
|
||||||
@end
|
|
||||||
|
|
||||||
@implementation XPCandyTreeAnimationManager
|
|
||||||
|
|
||||||
- (void)receiveCandyTreeGift:(CandyTreeGiftInfoModel *)giftInfo {
|
|
||||||
XPCandyTreeGiftView * newAnimaView = [[XPCandyTreeGiftView alloc] init];
|
|
||||||
newAnimaView.giftInfo = giftInfo;
|
|
||||||
NSString * giftTitle = [NSString stringWithFormat:@"%@ x %d", giftInfo.prizeName, giftInfo.prizeNum];
|
|
||||||
CGFloat widht = [giftTitle boundingRectWithSize:CGSizeMake(200, CGFLOAT_MAX) options:NSStringDrawingUsesFontLeading | NSStringDrawingUsesLineFragmentOrigin attributes:@{NSFontAttributeName:[UIFont systemFontOfSize:10]} context:nil].size.width + 10;
|
|
||||||
newAnimaView.frame = CGRectMake(7, 291, widht, KitemHeight);
|
|
||||||
self.offsetY = newAnimaView.center.y;
|
|
||||||
newAnimaView.alpha = 0;
|
|
||||||
///把所有收到的礼物加到队列中
|
|
||||||
[self.giftAnimateQueue addObject:newAnimaView];
|
|
||||||
if (self.timer == nil) {
|
|
||||||
[self startTheGiftQueueTimer];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//扫描礼物队列
|
|
||||||
- (void)startTheGiftQueueTimer {
|
|
||||||
///没0.3秒刷新一次
|
|
||||||
NSTimeInterval period = 0.3; //设置时间间隔
|
|
||||||
dispatch_queue_t queue = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0);
|
|
||||||
dispatch_source_t _timer = dispatch_source_create(DISPATCH_SOURCE_TYPE_TIMER, 0, 0, queue); dispatch_source_set_timer(_timer, dispatch_walltime(NULL, 0), period * NSEC_PER_SEC, 0); //每秒执行
|
|
||||||
dispatch_source_set_event_handler(_timer, ^{
|
|
||||||
if (self.giftAnimateQueue.count > 0) {
|
|
||||||
dispatch_sync(dispatch_get_main_queue(), ^{
|
|
||||||
//handle gift
|
|
||||||
if (!self.isAnimationing) {
|
|
||||||
if (self.giftAnimateQueue.count > 0) {
|
|
||||||
[self beginSendGiftAnimation1];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
dispatch_source_cancel(_timer);
|
|
||||||
self.timer = nil;
|
|
||||||
}
|
|
||||||
|
|
||||||
});
|
|
||||||
dispatch_resume(_timer);
|
|
||||||
self.timer = _timer;
|
|
||||||
}
|
|
||||||
|
|
||||||
- (void)beginSendGiftAnimation1 {
|
|
||||||
if (self.giftVisiablePool.count == 0) {///当前没有显示
|
|
||||||
self.isAnimationing = YES;
|
|
||||||
XPCandyTreeGiftView * animaView = [self.giftAnimateQueue firstObject];
|
|
||||||
[self.containerView addSubview:animaView];
|
|
||||||
[self.giftVisiablePool addObject:animaView];
|
|
||||||
////加到了 显示的池中 从队列中移除
|
|
||||||
[self.giftAnimateQueue removeObject:animaView];
|
|
||||||
///显示
|
|
||||||
XPCandyTreeAnimationModel * model = [[XPCandyTreeAnimationModel alloc] init];
|
|
||||||
model.animationKey = kPOPViewAlpha;
|
|
||||||
model.alphaFromValue = 0;
|
|
||||||
model.alphaToValue = 1;
|
|
||||||
model.beginTime = 0;
|
|
||||||
model.durationTime = 1;
|
|
||||||
model.removeTime = 2;
|
|
||||||
model.isRemoveAnimation = YES;
|
|
||||||
[animaView createAnimationWithAnimations:model finishBlock:^(BOOL finish) {
|
|
||||||
[animaView removeFromSuperview];
|
|
||||||
[self.giftVisiablePool removeObject:animaView];
|
|
||||||
} complete:^(BOOL complete) {
|
|
||||||
self.isAnimationing = NO;
|
|
||||||
}];
|
|
||||||
|
|
||||||
} else if(self.giftVisiablePool.count == 1) {///当前显示一个
|
|
||||||
self.isAnimationing = YES;
|
|
||||||
///在第一个已经显示的情况下 并且已经移除了的话 如果还有的话 那就继续显示第二个
|
|
||||||
XPCandyTreeGiftView * currentVisibalView = [self.giftVisiablePool objectAtIndex:0];
|
|
||||||
currentVisibalView.alpha = 1;
|
|
||||||
///显示第二的时候 需要把第一个的动画 取消不然等会第一个就消失了
|
|
||||||
[currentVisibalView canclueRemoveAnimation];
|
|
||||||
///需要显示view
|
|
||||||
XPCandyTreeGiftView * needVisiableReceiveInfor = [self.giftAnimateQueue objectAtIndex:0];
|
|
||||||
needVisiableReceiveInfor.alpha = 1;
|
|
||||||
[self.containerView addSubview:needVisiableReceiveInfor];
|
|
||||||
[self.containerView bringSubviewToFront:currentVisibalView];
|
|
||||||
[self.giftVisiablePool addObject:needVisiableReceiveInfor];
|
|
||||||
[self.giftAnimateQueue removeObject:needVisiableReceiveInfor];
|
|
||||||
|
|
||||||
XPCandyTreeAnimationModel * secondModel = [[XPCandyTreeAnimationModel alloc] init];
|
|
||||||
secondModel.animationKey = kPOPViewCenter;
|
|
||||||
secondModel.offsetFromY = self.offsetY;
|
|
||||||
secondModel.offsetToY = self.offsetY-KitemHeight - KitemMargin;
|
|
||||||
secondModel.beginTime = 0;
|
|
||||||
secondModel.durationTime = 1;
|
|
||||||
secondModel.isRemoveAnimation = YES;
|
|
||||||
secondModel.removeTime = 2;
|
|
||||||
[currentVisibalView createAnimationWithAnimations:secondModel finishBlock:^(BOOL finish) {
|
|
||||||
///a 1-0 结束的时候
|
|
||||||
[currentVisibalView removeFromSuperview];
|
|
||||||
[self.giftAnimateQueue removeObject:currentVisibalView];
|
|
||||||
///结束的时候才移除队列
|
|
||||||
[self.giftAnimateQueue removeObject:needVisiableReceiveInfor];
|
|
||||||
[needVisiableReceiveInfor removeFromSuperview];
|
|
||||||
} complete:^(BOOL complete) {
|
|
||||||
self.isAnimationing = NO;
|
|
||||||
}];
|
|
||||||
}else if(self.giftVisiablePool.count == 2) {///当前显示两个
|
|
||||||
self.isAnimationing = YES;
|
|
||||||
///最上面的view
|
|
||||||
XPCandyTreeGiftView * topVisiableView = [self.giftVisiablePool objectAtIndex:0];
|
|
||||||
///中间的那个view
|
|
||||||
XPCandyTreeGiftView * middleVisiableView = [self.giftVisiablePool objectAtIndex:1];
|
|
||||||
|
|
||||||
///需要显示的的那个view
|
|
||||||
XPCandyTreeGiftView * needVisiableView = [self.giftAnimateQueue objectAtIndex:0];
|
|
||||||
[self.containerView addSubview:needVisiableView];
|
|
||||||
[self.giftVisiablePool addObject:needVisiableView];
|
|
||||||
[self.giftAnimateQueue removeObject:needVisiableView];
|
|
||||||
///取消移除的动画
|
|
||||||
[topVisiableView canclueRemoveAnimation];
|
|
||||||
[middleVisiableView canclueRemoveAnimation];
|
|
||||||
|
|
||||||
XPCandyTreeAnimationModel * topPositionModel = [[XPCandyTreeAnimationModel alloc] init];
|
|
||||||
topPositionModel.animationKey = kPOPViewCenter;
|
|
||||||
topPositionModel.offsetToY = self.offsetY -KitemHeight * 2 - KitemMargin * 2;
|
|
||||||
topPositionModel.offsetFromY = self.offsetY -KitemHeight - KitemMargin;
|
|
||||||
topPositionModel.beginTime = 0;
|
|
||||||
topPositionModel.durationTime = 1;
|
|
||||||
topPositionModel.isRemoveAnimation = YES;
|
|
||||||
topPositionModel.removeTime = 4;
|
|
||||||
[topVisiableView createAnimationWithAnimations:topPositionModel finishBlock:^(BOOL finish) {
|
|
||||||
[topVisiableView removeFromSuperview];
|
|
||||||
[self.giftVisiablePool removeObject:topVisiableView];
|
|
||||||
[middleVisiableView removeAmimation];
|
|
||||||
} complete:^(BOOL complete) {
|
|
||||||
|
|
||||||
}];
|
|
||||||
|
|
||||||
XPCandyTreeAnimationModel * middlePositionModel = [[XPCandyTreeAnimationModel alloc] init];
|
|
||||||
middlePositionModel.animationKey = kPOPViewCenter;
|
|
||||||
middlePositionModel.offsetToY = self.offsetY -KitemHeight - KitemMargin;
|
|
||||||
middlePositionModel.offsetFromY = self.offsetY;
|
|
||||||
middlePositionModel.beginTime = 0.5;
|
|
||||||
middlePositionModel.durationTime = 1;
|
|
||||||
middlePositionModel.isRemoveAnimation = NO;
|
|
||||||
[middleVisiableView createAnimationWithAnimations:middlePositionModel finishBlock:^(BOOL finish) {
|
|
||||||
[middleVisiableView removeFromSuperview];
|
|
||||||
[self.giftVisiablePool removeObject:topVisiableView];
|
|
||||||
[needVisiableView removeAmimation];
|
|
||||||
} complete:^(BOOL complete) {
|
|
||||||
|
|
||||||
}];
|
|
||||||
|
|
||||||
///显示
|
|
||||||
XPCandyTreeAnimationModel * dowAlphtmodel = [[XPCandyTreeAnimationModel alloc] init];
|
|
||||||
dowAlphtmodel.animationKey = kPOPViewAlpha;
|
|
||||||
dowAlphtmodel.alphaFromValue = 0;
|
|
||||||
dowAlphtmodel.alphaToValue = 1;
|
|
||||||
dowAlphtmodel.beginTime = 1;
|
|
||||||
dowAlphtmodel.durationTime = 1;
|
|
||||||
dowAlphtmodel.isRemoveAnimation = NO;
|
|
||||||
[needVisiableView createAnimationWithAnimations:dowAlphtmodel finishBlock:^(BOOL finish) {
|
|
||||||
[self.giftVisiablePool removeObject:needVisiableView];
|
|
||||||
[needVisiableView removeFromSuperview];
|
|
||||||
} complete:^(BOOL complete) {
|
|
||||||
self.isAnimationing = NO;
|
|
||||||
}];
|
|
||||||
} else if(self.giftVisiablePool.count == 3) {///当前显示三个的
|
|
||||||
self.isAnimationing = YES;
|
|
||||||
///最上面的view
|
|
||||||
XPCandyTreeGiftView * topVisiableView = [self.giftVisiablePool objectAtIndex:0];
|
|
||||||
///中间的那个view
|
|
||||||
XPCandyTreeGiftView * middleVisiableView = [self.giftVisiablePool objectAtIndex:1];
|
|
||||||
///底部的那个view
|
|
||||||
XPCandyTreeGiftView * downVisiavleView = [self.giftVisiablePool objectAtIndex:2];
|
|
||||||
///需要显示的view
|
|
||||||
XPCandyTreeGiftView * needVisiavleView = [self.giftAnimateQueue objectAtIndex:0];
|
|
||||||
[self.containerView addSubview:needVisiavleView];
|
|
||||||
|
|
||||||
[self.giftVisiablePool addObject:needVisiavleView];
|
|
||||||
///移除最上面的哪一个
|
|
||||||
[self.giftVisiablePool removeObject:topVisiableView];
|
|
||||||
|
|
||||||
[self.giftAnimateQueue removeObject:needVisiavleView];
|
|
||||||
///取消移除的动画
|
|
||||||
[topVisiableView canclueRemoveAnimation];
|
|
||||||
[middleVisiableView canclueRemoveAnimation];
|
|
||||||
[downVisiavleView canclueRemoveAnimation];
|
|
||||||
|
|
||||||
///隐藏
|
|
||||||
XPCandyTreeAnimationModel * model = [[XPCandyTreeAnimationModel alloc] init];
|
|
||||||
model.animationKey = kPOPViewAlpha;
|
|
||||||
model.alphaFromValue = 1;
|
|
||||||
model.alphaToValue = 0;
|
|
||||||
model.beginTime = 0;
|
|
||||||
model.durationTime = 0.5;
|
|
||||||
model.isRemoveAnimation = NO;
|
|
||||||
[topVisiableView createAnimationWithAnimations:model finishBlock:^(BOOL finish) {///消失动画完成
|
|
||||||
|
|
||||||
} complete:^(BOOL complete) {///这一组动画完成
|
|
||||||
[topVisiableView removeFromSuperview];
|
|
||||||
}];
|
|
||||||
|
|
||||||
|
|
||||||
XPCandyTreeAnimationModel * middlePositionModel = [[XPCandyTreeAnimationModel alloc] init];
|
|
||||||
middlePositionModel.animationKey = kPOPViewCenter;
|
|
||||||
middlePositionModel.offsetToY = self.offsetY -KitemHeight * 2 - KitemMargin * 2;
|
|
||||||
middlePositionModel.offsetFromY = self.offsetY -KitemHeight - KitemMargin;
|
|
||||||
middlePositionModel.beginTime = 0.5;
|
|
||||||
middlePositionModel.durationTime = 1;
|
|
||||||
middlePositionModel.isRemoveAnimation = YES;
|
|
||||||
middlePositionModel.removeTime = 4;
|
|
||||||
[middleVisiableView createAnimationWithAnimations:middlePositionModel finishBlock:^(BOOL finish) {
|
|
||||||
[middleVisiableView removeFromSuperview];
|
|
||||||
[downVisiavleView removeAmimation];
|
|
||||||
[self.giftVisiablePool removeObject:middleVisiableView];
|
|
||||||
} complete:^(BOOL complete) {
|
|
||||||
///动画已经上去了 可以开始下一个动画
|
|
||||||
}];
|
|
||||||
|
|
||||||
XPCandyTreeAnimationModel * downPositionModel = [[XPCandyTreeAnimationModel alloc] init];
|
|
||||||
downPositionModel.animationKey = kPOPViewCenter;
|
|
||||||
downPositionModel.offsetToY = self.offsetY -KitemHeight - KitemMargin;
|
|
||||||
downPositionModel.offsetFromY = self.offsetY;
|
|
||||||
downPositionModel.beginTime = 1;
|
|
||||||
downPositionModel.durationTime = 1;
|
|
||||||
downPositionModel.isRemoveAnimation = NO;
|
|
||||||
[downVisiavleView createAnimationWithAnimations:downPositionModel finishBlock:^(BOOL finish) {
|
|
||||||
[downVisiavleView removeFromSuperview];
|
|
||||||
[self.giftVisiablePool removeObject:downVisiavleView];
|
|
||||||
[needVisiavleView removeAmimation];
|
|
||||||
} complete:^(BOOL complete) {
|
|
||||||
|
|
||||||
}];
|
|
||||||
|
|
||||||
///最下面的那个
|
|
||||||
XPCandyTreeAnimationModel * newModel = [[XPCandyTreeAnimationModel alloc] init];
|
|
||||||
newModel.animationKey = kPOPViewAlpha;
|
|
||||||
newModel.alphaFromValue = 0;
|
|
||||||
newModel.alphaToValue = 1;
|
|
||||||
newModel.beginTime = 1.5;
|
|
||||||
newModel.durationTime = 0.5;
|
|
||||||
newModel.isRemoveAnimation = NO;
|
|
||||||
[needVisiavleView createAnimationWithAnimations:newModel finishBlock:^(BOOL finish) {///消失动画完成
|
|
||||||
[needVisiavleView removeFromSuperview];
|
|
||||||
[self.giftVisiablePool removeObject:needVisiavleView];
|
|
||||||
} complete:^(BOOL complete) {///这一组动画完成
|
|
||||||
self.isAnimationing = NO;
|
|
||||||
}];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#pragma mark - Getters And Setters
|
|
||||||
- (NSMutableArray<XPCandyTreeGiftView *> *)giftAnimateQueue {
|
|
||||||
if (!_giftAnimateQueue) {
|
|
||||||
_giftAnimateQueue = [NSMutableArray array];
|
|
||||||
}
|
|
||||||
return _giftAnimateQueue;
|
|
||||||
}
|
|
||||||
|
|
||||||
- (NSMutableArray<XPCandyTreeGiftView *> *)giftVisiablePool {
|
|
||||||
if (!_giftVisiablePool) {
|
|
||||||
_giftVisiablePool = [NSMutableArray array];
|
|
||||||
}
|
|
||||||
return _giftVisiablePool;
|
|
||||||
}
|
|
||||||
@end
|
|
@@ -12,12 +12,6 @@ NS_ASSUME_NONNULL_BEGIN
|
|||||||
@interface XPCandyTreeGiftView : UIView
|
@interface XPCandyTreeGiftView : UIView
|
||||||
///礼物的信息
|
///礼物的信息
|
||||||
@property (nonatomic,strong) CandyTreeGiftInfoModel *giftInfo;
|
@property (nonatomic,strong) CandyTreeGiftInfoModel *giftInfo;
|
||||||
///取消动画
|
|
||||||
- (void)canclueRemoveAnimation;
|
|
||||||
///隐藏View
|
|
||||||
- (void)removeAmimation;
|
|
||||||
/// 开始动画 finishBlock 是一组动画完成 比如 alpha 0-1 然后再 1-0 complete 是XPCandyTreeAnimationModel 中的动画完成
|
|
||||||
- (void)createAnimationWithAnimations:(XPCandyTreeAnimationModel *)model finishBlock:(void(^)(BOOL finish))finishBlock complete:(void(^)(BOOL complete))complete;
|
|
||||||
@end
|
@end
|
||||||
|
|
||||||
NS_ASSUME_NONNULL_END
|
NS_ASSUME_NONNULL_END
|
||||||
|
@@ -31,61 +31,6 @@
|
|||||||
}
|
}
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
#pragma mark - Public Method
|
|
||||||
///取消动画
|
|
||||||
- (void)canclueRemoveAnimation {
|
|
||||||
[[self class] cancelPreviousPerformRequestsWithTarget:self];
|
|
||||||
}
|
|
||||||
|
|
||||||
/// 开始动画
|
|
||||||
- (void)createAnimationWithAnimations:(XPCandyTreeAnimationModel *)model finishBlock:(void(^)(BOOL finish))finishBlock complete:(void(^)(BOOL complete))complete {
|
|
||||||
self.FinishBlock = finishBlock;
|
|
||||||
///只有两个动画 一个平移的 一个alpha
|
|
||||||
if (model.animationKey == kPOPViewAlpha) {
|
|
||||||
POPBasicAnimation * OpacitySpring = [POPBasicAnimation animationWithPropertyNamed:kPOPViewAlpha];
|
|
||||||
OpacitySpring.beginTime = CACurrentMediaTime() + model.beginTime;
|
|
||||||
OpacitySpring.toValue = @(model.alphaToValue);
|
|
||||||
OpacitySpring.fromValue = @(model.alphaFromValue);
|
|
||||||
OpacitySpring.duration = model.durationTime;
|
|
||||||
OpacitySpring.completionBlock = ^(POPAnimation *anim, BOOL finished) {
|
|
||||||
complete(finished);
|
|
||||||
};
|
|
||||||
if (model.isRemoveAnimation) {
|
|
||||||
[self performSelector:@selector(removeAmimation) withObject:nil afterDelay:model.removeTime];
|
|
||||||
}
|
|
||||||
[self pop_addAnimation:OpacitySpring forKey:@"OpacitySpring"];
|
|
||||||
} else {
|
|
||||||
POPBasicAnimation *anSpring = [POPBasicAnimation animationWithPropertyNamed:kPOPViewCenter];
|
|
||||||
anSpring.fromValue = [NSValue valueWithCGPoint:CGPointMake(self.center.x, model.offsetFromY)];;
|
|
||||||
anSpring.toValue = [NSValue valueWithCGPoint:CGPointMake(self.center.x, model.offsetToY)];;;
|
|
||||||
anSpring.beginTime = CACurrentMediaTime() + model.beginTime;
|
|
||||||
anSpring.duration = model.durationTime;
|
|
||||||
anSpring.completionBlock = ^(POPAnimation *anim, BOOL finished) {
|
|
||||||
complete(finished);
|
|
||||||
};
|
|
||||||
if (model.isRemoveAnimation) {
|
|
||||||
[self performSelector:@selector(removeAmimation) withObject:nil afterDelay:model.removeTime];
|
|
||||||
}
|
|
||||||
[self pop_addAnimation:anSpring forKey:@"OpacitySpring"];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
///隐藏View
|
|
||||||
- (void)removeAmimation {
|
|
||||||
POPBasicAnimation * OpacitySpring1 = [POPBasicAnimation animationWithPropertyNamed:kPOPViewAlpha];
|
|
||||||
OpacitySpring1.beginTime = CACurrentMediaTime();
|
|
||||||
OpacitySpring1.toValue = @(0);
|
|
||||||
OpacitySpring1.fromValue = @(1);
|
|
||||||
OpacitySpring1.duration = 0.5;
|
|
||||||
OpacitySpring1.completionBlock = ^(POPAnimation *anim, BOOL finished) {
|
|
||||||
if(finished && self.FinishBlock){
|
|
||||||
self.FinishBlock(YES);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
[self pop_addAnimation:OpacitySpring1 forKey:@"OpacitySpring"];
|
|
||||||
}
|
|
||||||
|
|
||||||
#pragma mark - Private Method
|
#pragma mark - Private Method
|
||||||
- (void)initSubViews {
|
- (void)initSubViews {
|
||||||
[self addSubview:self.backImageView];
|
[self addSubview:self.backImageView];
|
||||||
@@ -94,7 +39,7 @@
|
|||||||
|
|
||||||
- (void)initSubViewConstraints {
|
- (void)initSubViewConstraints {
|
||||||
[self.backImageView mas_makeConstraints:^(MASConstraintMaker *make) {
|
[self.backImageView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||||
make.left.right.centerY.mas_equalTo(self);
|
make.left.right.top.mas_equalTo(self);
|
||||||
make.height.mas_equalTo(19);
|
make.height.mas_equalTo(19);
|
||||||
}];
|
}];
|
||||||
|
|
||||||
|
@@ -15,7 +15,6 @@
|
|||||||
#import "ThemeColor.h"
|
#import "ThemeColor.h"
|
||||||
#import "TTPopup.h"
|
#import "TTPopup.h"
|
||||||
#import "XPHtmlUrl.h"
|
#import "XPHtmlUrl.h"
|
||||||
#import "XPCandyTreeAnimationManager.h"
|
|
||||||
///Model
|
///Model
|
||||||
#import "RoomInfoModel.h"
|
#import "RoomInfoModel.h"
|
||||||
#import "AttachmentModel.h"
|
#import "AttachmentModel.h"
|
||||||
@@ -25,9 +24,11 @@
|
|||||||
#import "XPRoomHalfWebView.h"
|
#import "XPRoomHalfWebView.h"
|
||||||
#import "XPCandyTreeMoreView.h"
|
#import "XPCandyTreeMoreView.h"
|
||||||
#import "XPCandyRankContainerView.h"
|
#import "XPCandyRankContainerView.h"
|
||||||
|
#import "XPCandyTreeGiftView.h"
|
||||||
///P
|
///P
|
||||||
#import "XPCandyTreePresenter.h"
|
#import "XPCandyTreePresenter.h"
|
||||||
#import "XPCandyTreeProtocol.h"
|
#import "XPCandyTreeProtocol.h"
|
||||||
|
#define KitemHeight (20 + 5)
|
||||||
@interface XPCandyTreeViewController ()<XPCandyTreeProtocol, NIMSystemNotificationManagerDelegate>
|
@interface XPCandyTreeViewController ()<XPCandyTreeProtocol, NIMSystemNotificationManagerDelegate>
|
||||||
///上面点击的view
|
///上面点击的view
|
||||||
@property (nonatomic,strong) UIView *topTapView;
|
@property (nonatomic,strong) UIView *topTapView;
|
||||||
@@ -77,6 +78,8 @@
|
|||||||
@property (nonatomic,strong) UIButton *subtractButton;
|
@property (nonatomic,strong) UIButton *subtractButton;
|
||||||
///摘糖果
|
///摘糖果
|
||||||
@property (nonatomic,strong) UIButton *pickButton;
|
@property (nonatomic,strong) UIButton *pickButton;
|
||||||
|
///动画的容器
|
||||||
|
@property (nonatomic,strong) UIView * animationView;
|
||||||
///摘糖果的个数
|
///摘糖果的个数
|
||||||
@property (nonatomic,assign) NSInteger numberCandy;
|
@property (nonatomic,assign) NSInteger numberCandy;
|
||||||
///糖果的信息
|
///糖果的信息
|
||||||
@@ -85,8 +88,6 @@
|
|||||||
@property (nonatomic,weak) id<RoomHostDelegate>hostDelegate;
|
@property (nonatomic,weak) id<RoomHostDelegate>hostDelegate;
|
||||||
///是否正在采摘
|
///是否正在采摘
|
||||||
@property (nonatomic,assign) BOOL isPicking;
|
@property (nonatomic,assign) BOOL isPicking;
|
||||||
///送礼物的动画
|
|
||||||
@property (nonatomic,strong) XPCandyTreeAnimationManager *giftManager;
|
|
||||||
@end
|
@end
|
||||||
|
|
||||||
@implementation XPCandyTreeViewController
|
@implementation XPCandyTreeViewController
|
||||||
@@ -135,7 +136,38 @@
|
|||||||
self.candyInfo.keyNum = result.remainKeyNum;
|
self.candyInfo.keyNum = result.remainKeyNum;
|
||||||
|
|
||||||
[result.prizeItemList enumerateObjectsUsingBlock:^(CandyTreeGiftInfoModel * _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
|
[result.prizeItemList enumerateObjectsUsingBlock:^(CandyTreeGiftInfoModel * _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
|
||||||
[self.giftManager receiveCandyTreeGift:obj];
|
if (obj.prizeLevel > 2) {
|
||||||
|
///取消所有的延迟加载的方法
|
||||||
|
[NSObject cancelPreviousPerformRequestsWithTarget:self];
|
||||||
|
|
||||||
|
XPCandyTreeGiftView * newAnimaView = [[XPCandyTreeGiftView alloc] init];
|
||||||
|
newAnimaView.giftInfo = obj;
|
||||||
|
NSString * giftTitle = [NSString stringWithFormat:@"%@ x %d", obj.prizeName, obj.prizeNum];
|
||||||
|
CGFloat widht = [giftTitle boundingRectWithSize:CGSizeMake(200, CGFLOAT_MAX) options:NSStringDrawingUsesFontLeading | NSStringDrawingUsesLineFragmentOrigin attributes:@{NSFontAttributeName:[UIFont systemFontOfSize:10]} context:nil].size.width + 10;
|
||||||
|
newAnimaView.frame = CGRectMake(0, 4 * (KitemHeight), widht, KitemHeight);
|
||||||
|
[self.animationView addSubview:newAnimaView];
|
||||||
|
|
||||||
|
if (self.animationView.subviews.count > 5) {
|
||||||
|
[self.animationView.subviews.firstObject removeFromSuperview];
|
||||||
|
}
|
||||||
|
for (int i=0; i < self.animationView.subviews.count; i++) {
|
||||||
|
XPCandyTreeGiftView * view = [self.animationView.subviews objectAtIndex:i];
|
||||||
|
NSInteger offsetY= (self.animationView.subviews.count - i) * KitemHeight;
|
||||||
|
[UIView animateWithDuration:0.1 animations:^{
|
||||||
|
CGRect rect = view.frame;
|
||||||
|
rect.origin.y = KitemHeight * 5 - offsetY;
|
||||||
|
view.frame = rect;
|
||||||
|
} completion:^(BOOL finished) {
|
||||||
|
if (i == (self.animationView.subviews.count -1)) {
|
||||||
|
[self.animationView.subviews enumerateObjectsUsingBlock:^(__kindof UIView * _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
|
||||||
|
[self performSelector:@selector(giftViewRemoveFromSuperView:) withObject:obj afterDelay:3];
|
||||||
|
}];
|
||||||
|
}
|
||||||
|
}];
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
}];
|
}];
|
||||||
|
|
||||||
@kWeakify(self);
|
@kWeakify(self);
|
||||||
@@ -182,6 +214,7 @@
|
|||||||
[self.backView addSubview:self.pickStackView];
|
[self.backView addSubview:self.pickStackView];
|
||||||
[self.backView addSubview:self.pickButton];
|
[self.backView addSubview:self.pickButton];
|
||||||
[self.backView addSubview:self.candyTreeTransView];
|
[self.backView addSubview:self.candyTreeTransView];
|
||||||
|
[self.backView addSubview:self.animationView];
|
||||||
|
|
||||||
[self.rankStackView addArrangedSubview:self.rankImageView];
|
[self.rankStackView addArrangedSubview:self.rankImageView];
|
||||||
[self.rankStackView addArrangedSubview:self.rankLabel];
|
[self.rankStackView addArrangedSubview:self.rankLabel];
|
||||||
@@ -292,7 +325,19 @@
|
|||||||
make.bottom.right.mas_equalTo(self.view);
|
make.bottom.right.mas_equalTo(self.view);
|
||||||
make.width.mas_equalTo(self.candyTreeTransView.mas_height).multipliedBy(kscale);
|
make.width.mas_equalTo(self.candyTreeTransView.mas_height).multipliedBy(kscale);
|
||||||
}];
|
}];
|
||||||
|
|
||||||
|
[self.animationView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||||
|
make.left.mas_equalTo(self.backView).offset(7);
|
||||||
|
make.bottom.mas_equalTo(self.backView).offset(-106);
|
||||||
|
make.width.mas_equalTo(150);
|
||||||
|
make.height.mas_equalTo(KitemHeight * 5);
|
||||||
|
}];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (void)giftViewRemoveFromSuperView:(UIView *)view {
|
||||||
|
[view removeFromSuperview];
|
||||||
|
}
|
||||||
|
|
||||||
#pragma mark - Event Response
|
#pragma mark - Event Response
|
||||||
- (void)moreTapRecognizer:(UITapGestureRecognizer *)tap {
|
- (void)moreTapRecognizer:(UITapGestureRecognizer *)tap {
|
||||||
XPCandyTreeMoreView * moreView = [[XPCandyTreeMoreView alloc] init];
|
XPCandyTreeMoreView * moreView = [[XPCandyTreeMoreView alloc] init];
|
||||||
@@ -621,12 +666,12 @@
|
|||||||
return _pickButton;
|
return _pickButton;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (XPCandyTreeAnimationManager *)giftManager {
|
- (UIView *)animationView {
|
||||||
if (!_giftManager) {
|
if (!_animationView) {
|
||||||
_giftManager = [[XPCandyTreeAnimationManager alloc] init];
|
_animationView = [[UIView alloc] init];
|
||||||
_giftManager.containerView = self.backView;
|
_animationView.backgroundColor = [UIColor clearColor];
|
||||||
}
|
}
|
||||||
return _giftManager;
|
return _animationView;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user