html动态散花代码,IOS实现签到特效(散花效果)的实例代码

本文讲述了IOS实现签到特效(散花效果)实例代码。分享给大家供大家参考,具体如下:

3fdbcb2b1e1809ec36f0e0db8b3f45ef.png

0dfac04bfadf8eee1fa45890873f27e2.png

散花特效

#import

/// 领取奖励成功

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

}];

});

//开始粒子效果

CAEmitterLayer *emitterLayer = addEmitterLayer(backgroundView,successWindow);

startAnimate(emitterLayer);

}

CAEmitterLayer *addEmitterLayer(UIView *view,UIView *window)

{

//色块粒子

CAEmitterCell *subCell1 = subCell(imageWithColor(EmitterColor_Red));

subCell1.name = @"red";

CAEmitterCell *subCell2 = subCell(imageWithColor(EmitterColor_Yellow));

subCell2.name = @"yellow";

CAEmitterCell *subCell3 = subCell(imageWithColor(EmitterColor_Blue));

subCell3.name = @"blue";

CAEmitterCell *subCell4 = subCell([UIImage imageNamed:@"success_star"]);

subCell4.name = @"star";

CAEmitterLayer *emitterLayer = [CAEmitterLayer layer];

emitterLayer.emitterPosition = window.center;

emitterLayer.emitterPosition = window.center;

emitterLayer.emitterSize = window.bounds.size;

emitterLayer.emitterMode = kCAEmitterLayerOutline;

emitterLayer.emitterShape = kCAEmitterLayerRectangle;

emitterLayer.renderMode = kCAEmitterLayerOldestFirst;

emitterLayer.emitterCells = @[subCell1,subCell2,subCell3,subCell4];

[view.layer addSublayer:emitterLayer];

return emitterLayer;

}

void startAnimate(CAEmitterLayer *emitterLayer)

{

CABasicAnimation *redBurst = [CABasicAnimation animationWithKeyPath:@"emitterCells.red.birthRate"];

redBurst.fromValue = [NSNumber numberWithFloat:30];

redBurst.toValue = [NSNumber numberWithFloat: 0.0];

redBurst.duration = 0.5;

redBurst.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionLinear];

CABasicAnimation *yellowBurst = [CABasicAnimation animationWithKeyPath:@"emitterCells.yellow.birthRate"];

yellowBurst.fromValue = [NSNumber numberWithFloat:30];

yellowBurst.toValue = [NSNumber numberWithFloat: 0.0];

yellowBurst.duration = 0.5;

yellowBurst.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionLinear];

CABasicAnimation *blueBurst = [CABasicAnimation animationWithKeyPath:@"emitterCells.blue.birthRate"];

blueBurst.fromValue = [NSNumber numberWithFloat:30];

blueBurst.toValue = [NSNumber numberWithFloat: 0.0];

blueBurst.duration = 0.5;

blueBurst.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionLinear];

CABasicAnimation *starBurst = [CABasicAnimation animationWithKeyPath:@"emitterCells.star.birthRate"];

starBurst.fromValue = [NSNumber numberWithFloat:30];

starBurst.toValue = [NSNumber numberWithFloat: 0.0];

starBurst.duration = 0.5;

starBurst.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionLinear];

CAAnimationGroup *group = [CAAnimationGroup animation];

group.animations = @[redBurst,yellowBurst,blueBurst,starBurst];

[emitterLayer addAnimation:group forKey:@"heartsBurst"];

}

CAEmitterCell *subCell(UIImage *image)

{

CAEmitterCell * cell = [CAEmitterCell emitterCell];

cell.name = @"heart";

cell.contents = (__bridge id _Nullable)image.CGImage;

// 缩放比例

cell.scale = 0.6;

cell.scaleRange = 0.6;

// 每秒产生的数量

// cell.birthRate = 40;

cell.lifetime = 20;

// 每秒变透明的速度

// snowCell.alphaSpeed = -0.7;

// snowCell.redSpeed = 0.1;

// 秒速

cell.velocity = 200;

cell.velocityRange = 200;

cell.yAcceleration = 9.8;

cell.xAcceleration = 0;

//掉落的角度范围

cell.emissionRange = M_PI;

cell.scaleSpeed = -0.05;

cell.alphaSpeed = -0.3;

cell.spin = 2 * M_PI;

cell.spinRange = 2 * M_PI;

return cell;

}

UIImage *imageWithColor(UIColor *color)

{

CGRect rect = CGRectMake(0, 0, 13, 17);

UIGraphicsBeginImageContext(rect.size);

CGContextRef context = UIGraphicsGetCurrentContext();

CGContextSetFillColorWithColor(context, [color CGColor]);

CGContextFillRect(context, rect);

UIImage *image = UIGraphicsGetImageFromCurrentImageContext();

UIGraphicsEndImageContext();

return image;

}

@end

领取奖励成功提示框

#import

/// 领取奖励成功提示框

@interface RewardSuccessWindow : UIView

@end

#import "RewardSuccessWindow.h"

static CGFloat SuccessWindow_width = 270;

static CGFloat SuccessWindow_hight = 170;

@implementation RewardSuccessWindow

(instancetype)initWithFrame:(CGRect)frame

{

CGSize screenSize = [UIScreen mainScreen].bounds.size;

self = [super initWithFrame:CGRectMake((screenSize.width - SuccessWindow_width)/2.0 , (screenSize.height - SuccessWindow_hight)/2.0, SuccessWindow_width, SuccessWindow_hight)];

if (self)

{

[self configSubViews];

}

return self;

}

- (void)configSubViews

{

self.backgroundColor = [UIColor whiteColor];

self.layer.cornerRadius = 10;

self.layer.masksToBounds = YES;

UILabel *titleLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, 45, SuccessWindow_width, 22)];

titleLabel.text = @"恭喜您,领取成功!";

titleLabel.font = [UIFont systemFontOfSize:19.0];

titleLabel.textAlignment = NSTextAlignmentCenter;

[self addSubview:titleLabel];

UILabel *expLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, 75, SuccessWindow_width, 43)];

expLabel.font = [UIFont systemFontOfSize:15];

expLabel.textAlignment = NSTextAlignmentCenter;

[self addSubview:expLabel];

NSString *string = @"获得经验:+6";

NSMutableAttributedString *attributedString = [[NSMutableAttributedString alloc] initWithString:string];

[attributedString addAttribute:NSFontAttributeName value:[UIFont systemFontOfSize:15] range:NSMakeRange(0, string.length)];

[attributedString addAttribute:NSFontAttributeName value:[UIFont fontWithName:@"MarkerFelt-Thin" size:35] range:NSMakeRange(5,2)];

NSShadow *shadow =[[NSShadow alloc] init];

shadow.shadowOffset = CGSizeMake(1, 3);

[attributedString addAttribute:NSShadowAttributeName value:shadow range:NSMakeRange(5,2)];

[attributedString addAttribute:NSForegroundColorAttributeName value:[UIColor yellowColor] range:NSMakeRange(5,2)];

expLabel.attributedText = attributedString;

UILabel *bottomLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, 135, SuccessWindow_width, 22)];

bottomLabel.text = @"可以在我的->我的奖励中查看获得奖励";

bottomLabel.font = [UIFont systemFontOfSize:13.0];

bottomLabel.textAlignment = NSTextAlignmentCenter;

bottomLabel.textColor = [UIColor colorWithRed:177/255.0 green:177/255.0 blue:177/255.0 alpha:1];

[self addSubview:bottomLabel];

}

@end

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/440954.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

小程序中input标签没有反应_鸢尾花预测:如何创建机器学习Web应用程序?

全文共2485字,预计学习时长12分钟图源:unsplash数据科学的生命周期主要包括数据收集、数据清理、探索性数据分析、模型构建和模型部署。作为数据科学家或机器学习工程师,能够部署数据科学项目非常重要,这有助于完成数据科学生命周…

潢川高中2021高考成绩查询,潢川高中2020年秋季学期高一期中考试成绩分析

潢川高中2020年秋季学期高一期中语文试卷分析分析人:李四海本次试卷结构与高考试卷结构一致,局部作了调整。如默写由6分增到10分,散文阅读由15分压到13分,文言文翻译共8分。经学科组集体讨论,作如下分析:一…

win10安装ensp启动40_装系统不求人,快速制作启动U盘,傻瓜式重装WIN10

在以前如果我们的电脑系统损坏,无法进入WINDOWS系统,在需要重装WINDOWS系统时,一般的做法是,下载一个WINDOWS系统镜像,制作一个PE启动盘,在PE里安装系统镜像。这样传统的WINDOWS系统重装过程麻烦且耗时。而…

如何拆计算机主机箱,一种方便拆卸的计算机主机箱的制作方法

本发明涉及计算机设备技术领域,具体为一种方便拆卸的计算机主机箱。背景技术:计算机主机指计算机硬件系统中用于放置主板及其他主要部件的容器,通常包括CPU、内存、硬盘、光驱、电源、以及其他输入输出控制器和接口,如控制器、显卡…

java word转html 乱码 poi,java word转html poi

java word转html poi[2021-01-29 15:50:39] 简介:php去除nbsp的方法:首先创建一个PHP代码示例文件;然后通过“preg_replace("/(\s|\&nbsp\;| |\xc2\xa0)/", " ", strip_tags($val));”方法去除所有nbsp即可。推荐:…

未来计算机的功能猜想,全方位猜想,未来计算机发展详细预测

全方位猜想,未来计算机发展详细预测随着计算机技术的发展,PC将成为我们工作上的工具,生活中的控制中心是必然的事情。从网友的文章中,我们可以了解到计算机的未来充满了变数。性能的大幅度提高是不可置疑的,而实现性能…

github怎么切换到gitee_AOSP-RISCV 的开源仓库在 Gitee 上新建了镜像

前阵子在知乎上给大家介绍了我们在移植 AOSP 到 RISC-V 上的第一步: 汪辰:第一个 RISC-V 上的“Android 最小系统”​zhuanlan.zhihu.com目前所有的工作成果都是开源在 Github 上的,移植改动涉及的子仓库达到 9 个,所有源码下载下来达到 537M…

联想微型计算机拆,联想10064一体机拆机,联想一体机硬盘怎么拆

电脑现在在我们生活中有着非常广泛的用途,不论是我们的工作还是学习都离不开电脑的辅助。我们工作时可以用电脑进行记录档案资料,学习时可以用电脑查阅资料,及时解决一些学习上遇到的疑问。有了电脑之后我们的工作学习效率都得到了非常大的提…

【CodeForces - 471C】MUH and House of Cards (思维,找规律)

题干: Polar bears Menshykov and Uslada from the zoo of St. Petersburg and elephant Horace from the zoo of Kiev decided to build a house of cards. For that theyve already found a hefty deck of n playing cards. Lets describe the house they want t…

大一计算机绩点3算什么水平,绩点只有3?我可以解释一下

放张图文无关压压惊最近开始申请学业奖学金了,大家开始计算自己的绩点,我也算了一下自己的成绩,结果是比3多一点点(如果没有算错的话)。我觉得这是一个比较合适的数字,没有比3小已经很满足了,毕竟学的并不好&#xff0…

不能用了 重装系统git_怎么用光盘重装系统?

身边没有U盘,电脑无法进入操作系统,只有一个系统光盘如何给电脑重装系统呢?受条件限制不能通过小白在线安装和U盘重装,今天教大家怎么用光盘重装系统吧。光盘重装系统准备工作1、保证电脑带有光驱功能,并且光驱处于正常…

浙江经济职业技术学院计算机排名,浙江经济职业技术学院排名第几

关于浙江经济职业技术学院排名的问题考生问: 关于浙江经济职业技术学院的排名,我想抛给小编姐姐几个问题哦。一、浙江经济职业技术学院今年排名第几?对,指的是全国千余所专科院校当中的排名哦;二、浙江经济职业技术学院…

python去除图像光照不均匀_低光照环境下图像增强相关

Low-Light Image Enhancement via a Deep Hybrid Network [TIP2019]Underexposed Photo Enhancement using Deep Illumination Estimation[CVPR2019]---------Low-Light Image Enhancement via a Deep Hybrid Network [TIP2019]作者提出一个混合的网络来同时学习内容&#xff0…

w10计算机无法打印,老司机解答win10系统电脑无法打印的详细技巧

大家在使用电脑工作的时候会遇到win10系统电脑无法打印的问题,于是就有一些朋友到本站咨询win10系统电脑无法打印问题的解决步骤。解决win10系统电脑无法打印的问题非常简单,只需要你依照1、请确保打印机已打开并连接到你的电脑。 2、如果仍然无法工作&…

vb外部调用autocad_AutoCAD教程之图块的各种相关操作和概念

制图过程中,有时常需要插入某些特殊符号供图形中使用,此时就需要运用到图块及图块属性功能。利用图块与属性功能绘图,可以有效地提高作图效率与绘图质量。也是绘制复杂图形的重要组成部分。一、图块的特点图块是一组图形实体的总称&#xff0…

【CodeForces - 520C】DNA Alignment (快速幂,思维)

题干: Vasya became interested in bioinformatics. Hes going to write an article about similar cyclic DNA sequences, so he invented a new method for determining the similarity of cyclic sequences. Lets assume that strings s and t have the same l…

echart 动画 饼图_echarts构建关系图,节点可收缩和展开,可添加点击事件

echarts下载及使用ECharts,一个使用 JavaScript 实现的开源可视化库,可以流畅的运行在 PC 和移动设备上,兼容当前绝大部分浏览器(IE8/9/10/11,Chrome,Firefox,Safari等),…

三菱socket通信实例_三菱自动化产品相关知识整理汇总

先从应用最广泛的PLC产品来说下:小型机:FX3S、FX3G、FX3U、FX5U 中型机:L系列大型机:Q系列、R系列Q是比较老的产品,也是现在大型机里面应用比较普遍的产品,在Q之后开发出性价比比较高的产品L系列和性能更高…

英语人机考试计算机算分吗,英语人机对话考试技巧

1英语 人机对话考试技巧目前要在英语口语人机对话中获得好的成绩,除了了解测试的特点之外,还需掌握一定的技巧、这对提高英语口语人机对话成绩将起到事半功倍的作用。接下来小编告诉你英语人机对话考试技巧。调整心态,临场莫慌听力不同于其他…

玛纽尔扫地机器人怎样_扫地机器人哪个牌子好?满足日常清洁需求才值得推荐...

随着科技的发展,越来越多的家庭入手扫地机器人来代替日常打扫,而扫地机器人以其高智能化、自动化和便捷的清洁方式也获得了大部分家庭的喜爱。从市面上出售的扫地机器人来看,就清洁方面足以满足大部分家庭的需求,但是更进一步的定位巡航技术、扫拖一体功能以及强劲的续航保证,却…