签到特效(散花效果)

本文介绍如何创建一款签到应用的散花特效,当用户成功领取奖励时,展示具有动态散花效果的提示框,提升用户体验。
摘要由CSDN通过智能技术生成

点击领取奖励
这里写图片描述

散花特效

#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]
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值