green打不开range怎么开后盖

iOS 雪花动画与跑马灯
招聘信息:
授权转载,作者:这篇是接着上一篇《》, 关于动画效果的收集篇, 这篇介绍了跑马灯动画以及下落雪花动画, 请看, 话说最近怎么不在状态呢, 好伤感(囧~).跑马灯效果演示这里贴出使用代码, 详细请下载Demo查看,演示下载后, 在VC中这样使用, 当然Demo中也有体现-&(void)viewDidLoad&{
[super&viewDidLoad];
//&Do&any&additional&setup&after&loading&the&view.
self.view.backgroundColor&=&[UIColor&blackColor];
XTScrollLabelView&*drawMarqueeView&&=&[[XTScrollLabelView&alloc]&initWithFrame:CGRectMake(0,&0,&250.f,&20)];
drawMarqueeView.delegate&&&&&&&&&&=&
drawMarqueeView.marqueeDirection&&=&FromLeftT
drawMarqueeView.center&&&&&&&&&&&&=&self.view.
[self.view&addSubview:drawMarqueeView];
[drawMarqueeView&addContentView:[self&createLabelWithText:@"夏天是个很好的季节,&而夏天然后是简书的推荐作者,&喜欢分享!"
textColor:[self&randomColor]]];
[drawMarqueeView&startAnimation];
-&(UILabel&*)createLabelWithText:(NSString&*)text&textColor:(UIColor&*)textColor&{
NSString&*string&=&[NSString&stringWithFormat:@"&%@&",&text];
CGFloat&width&=&[string&widthWithStringAttribute:@{NSFontAttributeName&:&[UIFont&systemFontOfSize:14.f]}];
UILabel&&*label&&=&[[UILabel&alloc]&initWithFrame:CGRectMake(0,&0,&width,&20)];
label.font&&&&&&&=&[UIFont&systemFontOfSize:14.f];
label.text&&&&&&&=&
label.textColor&&=&textC
-&(UIColor&*)randomColor&{
return&[UIColor&colorWithRed:[self&randomValue]&green:[self&randomValue]&blue:[self&randomValue]&alpha:1];
-&(CGFloat)randomValue&{
return&arc4random()&%&256&/&255.f;
-&(void)drawMarqueeView:(XTScrollLabelView&*)drawMarqueeView&animationDidStopFinished:(BOOL)finished
[drawMarqueeView&stopAnimation];
dispatch_after(dispatch_time(DISPATCH_TIME_NOW,&(int64_t)(1.0&*&NSEC_PER_SEC)),&dispatch_get_main_queue(),&^{
[drawMarqueeView&addContentView:[self&createLabelWithText:[self&randomString]
textColor:[self&randomColor]]];
[drawMarqueeView&startAnimation];
-&(NSString&*)randomString&{
NSArray&*array&=&@[@"人帅",
@"开玩笑",
@"都是我编的,&前面的别跑"];
return&array[arc4random()&%&array.count];
}演示雪花动画代码演示--&在ViewDidLoad中这样写,&注释已经很详细
//&创建粒子Layer
CAEmitterLayer&*snowEmitter&=&[CAEmitterLayer&layer];
//&粒子发射位置
snowEmitter.emitterPosition&=&CGPointMake(120,0);
//&发射源的尺寸大小
snowEmitter.emitterSize&&&&&=&self.view.bounds.
//&发射模式
snowEmitter.emitterMode&&&&&=&kCAEmitterLayerS
//&发射源的形状
snowEmitter.emitterShape&&&&=&kCAEmitterLayerL
//&创建雪花类型的粒子
CAEmitterCell&*snowflake&&&&=&[CAEmitterCell&emitterCell];
//&粒子的名字
snowflake.name&=&@"snow";
//&粒子参数的速度乘数因子
snowflake.birthRate&=&20.0;
snowflake.lifetime&&=&120.0;
//&粒子速度
snowflake.velocity&&=&10.0;
//&粒子的速度范围
snowflake.velocityRange&=&10;
//&粒子y方向的加速度分量
snowflake.yAcceleration&=&2;
//&周围发射角度
snowflake.emissionRange&=&0.5&*&M_PI;
//&子旋转角度范围
snowflake.spinRange&=&0.25&*&M_PI;
snowflake.contents&&=&(id)[[UIImage&imageNamed:@"snow"]&CGImage];
//&设置雪花形状的粒子的颜色
snowflake.color&&&&&&=&[[UIColor&whiteColor]&CGColor];
snowflake.redRange&&&=&1.5f;
snowflake.greenRange&=&2.2f;
snowflake.blueRange&&=&2.2f;
snowflake.scaleRange&=&0.6f;
snowflake.scale&&&&&&=&0.7f;
snowEmitter.shadowOpacity&=&1.0;
snowEmitter.shadowRadius&&=&0.0;
snowEmitter.shadowOffset&&=&CGSizeMake(0.0,&0.0);
//&粒子边缘的颜色
snowEmitter.shadowColor&&=&[[UIColor&whiteColor]&CGColor];
//&添加粒子
snowEmitter.emitterCells&=&@[snowflake];
//&将粒子Layer添加进图层中
[self.view.layer&addSublayer:snowEmitter];
//&形成遮罩
UIImage&*image&&&&&&=&[UIImage&imageNamed:@"alpha"];
_layer&&&&&&&&&&&&&&=&[CALayer&layer];
_layer.frame&&&&&&&&=&(CGRect){CGPointZero,&self.view.bounds.size};
_layer.contents&&&&&=&(__bridge&id)(image.CGImage);
_layer.position&&&&&=&self.view.
snowEmitter.mask&&&&=&_
微信扫一扫
订阅每日移动开发及APP推广热点资讯公众号:CocoaChina
您还没有登录!请或
点击量7091点击量6144点击量5871点击量5353点击量3560点击量3301点击量3099点击量3000点击量2806
&2016 Chukong Technologies,Inc.
京公网安备89CAEmitterLayer(粒子系统)学习笔记
一、系统剖析
在UIKit中,粒子系统由两部分组成:
·&&&&&&一个或多个:发射器电池可以看作是单个粒子的原型(例如,一个单一的粉扑在一团烟雾)。当散发出一个粒子,UIKit根据这个发射粒子和定义的基础上创建一个随机粒子。此原型包括一些属性来控制粒子的图片,颜色,方向,运动,缩放比例和生命周期。
·&&&&&&一个或多个但通常只有一个:这个发射的层主要控制粒子的形状(例如,一个点,矩形或圆形)和发射的位置(例如,在矩形内,或边缘)。这个层具有全局的乘法器,可以施加到系统内的CAEmitterCells。这些给你一个简单的方法覆盖的所有粒子的变化。比如一个人为的例子将改变x雨来模拟风的速度。
基础是简单的,但这些参数却是相当微妙的。CAEmitterLayer有超过30种不同的参数进行自定义粒子的行为。下面,我就拼出来的一些特殊问题
二、不可测性
1、是什么让粒子系统成为一个随机的系统?
CAEmitterCell的属性一般有两个参数:一个均值和一个“cone”,比如velocity&和velocityRange。
默认情况下,这个“cone”是0,这就以为着所有粒子将具有相同的速度。通过改变这个“cone”,每个发射粒子会随机被扰动获得一个这个“cone”范围内的值。这点在Apple官方文档:&&有讲解:
Each layer has its ownrandom number generator state. Emitter cell
properties that are defined as amean and a range, such as a cell’s
speed, the value of the properties areuniformly distributed in the
interval [M - R/2, M + R/2].
2、发射的方向
CAEmitterCells有一个velocity(速度)的属性,这意味着发送方向上的速度。实际上这个发射的方向是通过emissionLongitude属性定义的。Apple这样阐述的:
The emission longitude is theorientation of the emission angle in
the xy-plane. it is also often referred toas the
-&(void)viewDidLoad&&
&&&&[super&viewDidLoad];&&
&&&&CAEmitterLayer&*emitterLayer&=&[CAEmitterLayer&layer];&&
&&&&emitterLayer.emitterPosition&=&self.view.&&
&&&&_emitterLayer&=&emitterL&&
&&&&[self.view.layer&addSublayer:emitterLayer];&&
&&&&CAEmitterCell&*funnyEmitterCell&=&[CAEmitterCell&emitterCell];&&
&&&&funnyEmitterCell.contents&=&(id)[UIImage&imageNamed:@"funny.jpg"].CGI&&
&&&&funnyEmitterCell.birthRate&=&10.0;&&
&&&&funnyEmitterCell.velocity&=&200.0;&&
&&&&funnyEmitterCell.lifetime&=&5.0;&&
&&&&funnyEmitterCell.scale&=&0.1;&&
&&&&&=&@"funny";&&
&&&&emitterLayer.emitterCells&=&[NSArray&arrayWithObject:funnyEmitterCell];&&
&&&&[self&bumpAngle];&&
&&&&UILabel&*angleLabel&=&[[UILabel&alloc]&initWithFrame:CGRectMake(20,&20,&100,&30)];&&
&&&&angleLabel.backgroundColor&=&[UIColor&clearColor];&&
&&&&[self.view&addSubview:angleLabel];&&
&&&&_angleLabel&=&angleL&&
-&(void)&bumpAngle&{&&
&&&&NSNumber&*emissionLongitude&=&[_emitterLayer&valueForKeyPath:@"emitterCells.funny.emissionLongitude"];&&
&&&&NSNumber&*nextLongitude&=&[NSNumber&numberWithFloat:[emissionLongitude&floatValue]&+&0.02];&&
&&&&[_emitterLayer&setValue:nextLongitude&forKeyPath:@"emitterCells.funny.emissionLongitude"];&&
&&&&_angleLabel.text&=&[NSString&stringWithFormat:@"%.0f&degrees",&[nextLongitude&floatValue]&*&180&/&M_PI];&&
&&&[self&performSelector:@selector(bumpAngle)&withObject:nil&afterDelay:0.1];&&
代码设置/结构说明:
1、CAEmitterCell
CAEmitterCell *effectCell = [CAEmitterCell
emitterCell];
effectCell 几个重要属性:
1).birthRate 顾名思义没有这个也就没有effectCell,这个必须要设置,具体含义是每秒某个点产生的effectCell数量
2).lifetime & lifetimeRange
表示effectCell的生命周期,既在屏幕上的显示时间要多长。
3).contents 这个和CALayer一样,只是用来设置图片
这个是当effectCell存在caeEmitter 的emitterCells中用来辨认的。用到setValue
forKeyPath比较有用
5).velocity & velocityRange & emissionRange
表示cell向屏幕右边飞行的速度 & 在右边什么范围内飞行& +-角度扩散
6).把cell做成array放进caeEmitter.emitterCells里去。caeEmitter.renderMode有个效果很不错,能变成火的就是kCAEmitterLayerAdditive
alphaRange:&&一个粒子的颜色alpha能改变的范围;
alphaSpeed:粒子透明度在生命周期内的改变速度;
birthrate:粒子参数的速度乘数因子;
blueRange:一个粒子的颜色blue&能改变的范围;
blueSpeed:&粒子blue在生命周期内的改变速度;
color:粒子的颜色
contents:是个CGImageRef的对象,既粒子要展现的图片;
contentsRect:应该画在contents里的子rectangle:
emissionLatitude:发射的z轴方向的角度
emissionLongitude:x-y平面的发射方向
emissionRange;周围发射角度&
emitterCells:粒子发射的粒子
enabled:粒子是否被渲染
greenrange:&一个粒子的颜色green&能改变的范围;
greenSpeed:&粒子green在生命周期内的改变速度;
lifetime:生命周期
lifetimeRange:生命周期范围
magnificationFilter:不是很清楚好像增加自己的大小
minificatonFilter:减小自己的大小
minificationFilterBias:减小大小的因子
name:粒子的名字
redRange:一个粒子的颜色red&能改变的范围;
redS&粒子red在生命周期内的改变速度;
scale:缩放比例:
scaleRange:缩放比例范围;
scaleSpeed:缩放比例速度:
spin:子旋转角度
spinrange:子旋转角度范围
style:不是很清楚:
velocity:速度
velocityRange:速度范围
xAcceleration:粒子x方向的加速度分量
yAcceleration:粒子y方向的加速度分量
zAcceleration:粒子z方向的加速度分量
2、CAEmitterLayer
CAEmitterLayer提供了一个基于Core
Animation的粒子发射系统,粒子用CAEmitterCell来初始化。粒子画在背景层盒边界上
birthRate:粒子产生系数,默认1.0;
emitterCells:&装着CAEmitterCell对象的数组,被用于把粒子投放到layer上;
emitterDepth:决定粒子形状的深度联系:emittershape
emitterMode:发射模式
NSString * const kCAEmitterLayerP
NSString * const kCAEmitterLayerO
NSString * const kCAEmitterLayerS
NSString * const kCAEmitterLayerV
emitterPosition:发射位置
emitterShape:发射源的形状:
NSString * const kCAEmitterLayerP
NSString * const kCAEmitterLayerL
NSString * const kCAEmitterLayerRectangle;
NSString * const kCAEmitterLayerC
NSString * const kCAEmitterLayerC
NSString * const kCAEmitterLayerS
emitterSize:发射源的尺寸大;
emitterZposition:发射源的z坐标位置;
lifetime:粒子生命周期
preservesDepth:不是多很清楚(粒子是平展在层上)
renderMode:渲染模式:
NSString * const kCAEmitterLayerUnordered;
NSString * const kCAEmitterLayerOldestFir
NSString * const kCAEmitterLayerOldestLast;
NSString * const kCAEmitterLayerBackToFro
NSString * const kCAEmitterLayerA
scale:粒子的缩放比例:
seed:用于初始化随机数产生的种子
spin:自旋转速度
velocity:粒子速度
iOS粒子系统CAEmitterLayer
下载Demo地址:
已投稿到:
以上网友发言只代表其个人观点,不代表新浪网的观点或立场。Green Range
The mondi Green Range was developed to promote environmentally preferable purchasing.
Conformity assessment | How is compliance with this ecolabel's standard ensured?
Conformity with Green Range's standard is verified by unknown.
Certification / registration required
Managing organization | Who manages this ecolabel?
For-profit
Also manages
Ecolabel Index pro | Subscription
Additional data available to subscribers: Ecolabel details |
What are the characteristics of the standard(s) related to this ecolabel?
Applicable life cycle
and supply chain phases Social and environmental attributes Mutual recognition with other
ecolabels Standard details, including standard document, review frequency
Ecolabel development | How were the standards for this ecolabel developed?
development and management process Standard-setting norms followed for development of the
ecolabel's standard Type of standard-setting process, external stakeholders, and funding
Conformity Assessment | How is compliance with this ecolabel's standard ensured?
Requirements to achieve certification (i.e. chain of custody, site visits, metrics) Audit /
surveillance requirements Duration of certification, time to achieve certification
Managing organization | Who manages this ecolabel?
Contact details, primary contact
Organizational details including year established, funding, and governance
Additional information | Including:
Compliance type (pass / fail / tiered)
Target audience (consumers / retailers / manufacturers / etc)
No contract — upgrade, downgrade, or cancel at any time.
FREE access for ecolabelling organisations.
Advertisement
Year ecolabel est.
Classification | Who, what, where
Product categories this ecolabel applies to
Where this ecolabel is found
Keep up to date | News, press
Recent tweets
Mailing list
Help build this site | Submit, suggest
Did we miss one?
Last updated: 16 January 2013
Ecolabel Index, the global directory of ecolabels, is brought to you by .
Big Room is a . We also operate .eco, a new web address for those committed to positive change for the planet.
& 2017 Big Room Inc. All rights reserved.

我要回帖

更多关于 python range 从1开始 的文章

 

随机推荐