散花特效
#import <Foundation/Foundation.h>
/// 领取奖励成功
@interface RewardSuccess : NSObject
/**
* 成功动画
*/
+ (void)show;
@end
#import "RewardSuccess.h"
#import "RewardSuccessWindow.h"
#define EmitterColor_Red [UIColor colorWithRed:255/255.0 green:0 blue:139/255.0 alpha:1]
#define EmitterColor_Yellow [UIColor colorWithRed:251/255.0 green:197/255.0 blue:13/255.0 alpha:1]
#define EmitterColor_Blue [UIColor colorWithRed:50/255.0 green:170/255.0 blue:207/255.0 alpha:1]
@implementation RewardSuccess
+ (void)show
{
UIWindow *window = [UIApplication sharedApplication].keyWindow;
UIView *backgroundView = [[UIView alloc] initWithFrame:window.bounds];
backgroundView.backgroundColor = [UIColor colorWithRed:0 green:0 blue:0 alpha:0.8];
[window addSubview:backgroundView];
RewardSuccessWindow *successWindow = [[RewardSuccessWindow alloc] initWithFrame:CGRectZero];
[backgroundView addSubview:successWindow];
//缩放
successWindow.transform=CGAffineTransformMakeScale(0.01f, 0.01f);
successWindow.alpha = 0;
[UIView animateWithDuration:0.4 animations:^{
successWindow.transform = CGAffineTransformMakeScale(1.0f, 1.0f);
successWindow.alpha = 1;
}];
//3s 消失
double delayInSeconds = 3;
dispatch_time_t delayInNanoSeconds = dispatch_time(DISPATCH_TIME_NOW, delayInSeconds * NSEC_PER_SEC);
dispatch_after(delayInNanoSeconds, dispatch_get_main_queue(), ^(void){
[UIView animateWithDuration:0.4 animations:^{
successWindow.transform = CGAffineTransformMakeScale(.3f, .3f);
successWindow.alpha = 0;
}completion:^(BOOL finished) {
[backgroundView removeFromSuperview]