1、CAEmitterCell粒子发射器的相关属性:
/* CoreAnimation - CAEmitterLayer.h Copyright (c) 2007-2017, Apple Inc. All rights reserved. *///iOS5中引入的新的子类,粒子引擎!可以实现粒子特效!#import@class CAEmitterCell;NS_ASSUME_NONNULL_BEGINCA_CLASS_AVAILABLE (10.6, 5.0, 9.0, 2.0)@interface CAEmitterLayer : CALayer//粒子发射器@property(nullable, copy) NSArray *emitterCells;//CAEmitterCell(粒子)@property float birthRate;//出生率,每秒生成多少个对象,默认1秒一个@property float lifetime;//对象生存时间默认1秒@property CGPoint emitterPosition;//发射器在xy平面的位置@property CGFloat emitterZPosition;//发射器在z平面的位置@property CGSize emitterSize;//发射源尺寸大小@property CGFloat emitterDepth;//发射器的深度@property(copy) NSString *emitterShape;//发射源形状@property(copy) NSString *emitterMode;//发射模式@property(copy) NSString *renderMode;//发射器渲染模式@property BOOL preservesDepth;//是否开启三维效果,默认NO@property float velocity;//每个粒子的运动速度@property float scale;//每个对象的初始缩放大小@property float spin;//自旋转速度@property unsigned int seed;//初始化随机数产生的种子@end/** `emitterShape' values. **/CA_EXTERN NSString * const kCAEmitterLayerPoint //点,粒子从一点发出! CA_AVAILABLE_STARTING (10.6, 5.0, 9.0, 2.0);CA_EXTERN NSString * const kCAEmitterLayerLine //线,粒子从一条线发出 CA_AVAILABLE_STARTING (10.6, 5.0, 9.0, 2.0);CA_EXTERN NSString * const kCAEmitterLayerRectangle //矩形,粒子从一个矩形中发出 CA_AVAILABLE_STARTING (10.6, 5.0, 9.0, 2.0);CA_EXTERN NSString * const kCAEmitterLayerCuboid //立方体,z屏幕有效果 CA_AVAILABLE_STARTING (10.6, 5.0, 9.0, 2.0);CA_EXTERN NSString * const kCAEmitterLayerCircle //圆形,粒子从圆形发出 CA_AVAILABLE_STARTING (10.6, 5.0, 9.0, 2.0);CA_EXTERN NSString * const kCAEmitterLayerSphere //球形--ForeverGuard博客园 CA_AVAILABLE_STARTING (10.6, 5.0, 9.0, 2.0);/** `emitterMode' values. **/CA_EXTERN NSString * const kCAEmitterLayerPoints //从发射器中发出 CA_AVAILABLE_STARTING (10.6, 5.0, 9.0, 2.0);CA_EXTERN NSString * const kCAEmitterLayerOutline //从发射器边缘发出 CA_AVAILABLE_STARTING (10.6, 5.0, 9.0, 2.0);CA_EXTERN NSString * const kCAEmitterLayerSurface //从发射器表面发出 CA_AVAILABLE_STARTING (10.6, 5.0, 9.0, 2.0);CA_EXTERN NSString * const kCAEmitterLayerVolume //从发射器中心发出 CA_AVAILABLE_STARTING (10.6, 5.0, 9.0, 2.0);/** `renderMode' values. **/CA_EXTERN NSString * const kCAEmitterLayerUnordered //粒子无序出现 CA_AVAILABLE_STARTING (10.6, 5.0, 9.0, 2.0);CA_EXTERN NSString * const kCAEmitterLayerOldestFirst //先声明的粒子渲染在最上层 CA_AVAILABLE_STARTING (10.6, 5.0, 9.0, 2.0);CA_EXTERN NSString * const kCAEmitterLayerOldestLast //后声明的粒子渲染在最上层 CA_AVAILABLE_STARTING (10.6, 5.0, 9.0, 2.0);CA_EXTERN NSString * const kCAEmitterLayerBackToFront //按照Z轴的前后顺序渲染 CA_AVAILABLE_STARTING (10.6, 5.0, 9.0, 2.0);CA_EXTERN NSString * const kCAEmitterLayerAdditive //粒子混合 CA_AVAILABLE_STARTING (10.6, 5.0, 9.0, 2.0);NS_ASSUME_NONNULL_END
2、CAEmitterCell粒子的相关属性:
#importNS_ASSUME_NONNULL_BEGINCA_CLASS_AVAILABLE (10.6, 5.0, 9.0, 2.0)@interface CAEmitterCell : NSObject {@private void *_attr[2]; void *_state; uint32_t _flags;}+ (instancetype)emitterCell;//初始化方法@property(nullable, copy) NSString *name;//粒子的名字@property(getter=isEnabled) BOOL enabled;//粒子的颜色@property float birthRate;//粒子出生率@property float lifetime;//生命周期@property float lifetimeRange;//生命周期增减范围@property CGFloat emissionLatitude;//粒子z轴方向的发射角度@property CGFloat emissionLongitude;//粒子在xy平面的发射角度@property CGFloat emissionRange;//粒子发射角度范围@property CGFloat velocity;//粒子运动速度@property CGFloat velocityRange;//粒子速度增减范围@property CGFloat xAcceleration;//粒子x方向的加速度@property CGFloat yAcceleration;//粒子y方向的加速度@property CGFloat zAcceleration;//粒子z方向的加速度@property CGFloat scale;//粒子缩放比例@property CGFloat scaleRange;//粒子缩放比例范围@property CGFloat scaleSpeed;//粒子缩放比例速度@property CGFloat spin;//粒子自旋转@property CGFloat spinRange;//粒子自旋转范围@property(nullable) CGColorRef color;//粒子的颜色@property float redRange;//粒子颜色red改变范围@property float greenRange;//粒子颜色green改变范围@property float blueRange;//粒子颜色blue改变范围@property float alphaRange;//粒子透明度alpha改变范围@property float redSpeed;//粒子颜色red在生命周期里改变速度@property float greenSpeed;//粒子颜色green在生命周期里改变速度@property float blueSpeed;//粒子颜色blue在生命周期里改变速度@property float alphaSpeed;//粒子透明度alpha在生命周期里改变速度@property(nullable, strong) id contents;//渲染粒子是个图片@property CGRect contentsRect;//渲染范围@property CGFloat contentsScale;//渲染区域缩放@property(copy) NSString *minificationFilter;//缩小@property(copy) NSString *magnificationFilter;//放大@property float minificationFilterBias;//缩小因子//默认值都是kCAFilterLinear即‘linear’//有3中设置:kCAFilterLinear,kCAFilterNearest,kCAFilterTrilinear//kCAFilterLinear:默认值,缩放平滑,但容易产生模糊效果//kCAFilterTrilinear:基本和kCAFilterLinear相同//kCAFilterNearest:速度快不会产生模糊,但会降低质量并像素化图像@property(nullable, copy) NSArray *emitterCells;//粒子发射的粒子(粒子也可以发射粒子,多层嵌套,烟花效果就是如此) @property(nullable, copy) NSDictionary *style;@end