標籤:private calayer ref flags 屬性 中心 立方體 nss nullable
1、CAEmitterCell粒子發射器的相關屬性:
/* CoreAnimation - CAEmitterLayer.h Copyright (c) 2007-2017, Apple Inc. All rights reserved. *///iOS5中引入的新的子類,粒子引擎!可以實現粒子特效!#import <QuartzCore/CALayer.h>@class CAEmitterCell;NS_ASSUME_NONNULL_BEGINCA_CLASS_AVAILABLE (10.6, 5.0, 9.0, 2.0)@interface CAEmitterLayer : CALayer//粒子發射器@property(nullable, copy) NSArray<CAEmitterCell *> *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粒子的相關屬性:
#import <QuartzCore/CALayer.h>NS_ASSUME_NONNULL_BEGINCA_CLASS_AVAILABLE (10.6, 5.0, 9.0, 2.0)@interface CAEmitterCell : NSObject <NSSecureCoding, CAMediaTiming>{@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<CAEmitterCell *> *emitterCells;//所有粒子@property(nullable, copy) NSDictionary *style;@end
iOS之CAEmitterLayer粒子引擎