Graphics Reference
In-Depth Information
//create particle emitter layer
CAEmitterLayer
*emitter = [
CAEmitterLayer
layer
];
emitter.
frame
=
self
.
containerView
.
bounds
;
[
self
.
containerView
.
layer
addSublayer
:emitter];
//configure emitter
emitter.
renderMode
=
kCAEmitterLayerAdditive
;
emitter.
emitterPosition
=
CGPointMake
(emitter.
frame
.
size
.
width
/
2.0
,
emitter.
frame
.
size
.
height
/
2.0
);
//create a particle template
CAEmitterCell
*cell = [[
CAEmitterCell
alloc
]
init
];
cell.
contents
= (
__bridge
id
)[
UIImage
imageNamed
:
@"Spark.png"
].
CGImage
;
cell.
birthRate
=
150
;
cell.
lifetime
=
5.0
;
cell.
color
= [
UIColor
colorWithRed
:
1
green
:
0.5
blue
:
0.1
alpha
:
1.0
].
CGColor
;
cell.
alphaSpeed
= -
0.4
;
cell.
velocity
=
50
;
cell.
velocityRange
=
50
;
cell.
emissionRange
=
M_PI
*
2.0
;
//add particle template to emitter
emitter.
emitterCells
=
@[
cell
]
;
}
@end