修改了糖果树开出的礼物大于2级才显示以及动画的问题

This commit is contained in:
fengshuo
2022-03-11 16:01:39 +08:00
parent 7df85463bb
commit 9be004d95f
6 changed files with 55 additions and 396 deletions

View File

@@ -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 */,

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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);
}]; }];

View File

@@ -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;
} }