Tutorial by Examples

You can create a CALayer and set its frame like this: Swift: let layer = CALayer() layer.frame = CGRect(x: 0, y: 0, width: 60, height: 80) Objective-C: CALayer *layer = [[CALayer alloc] init]; layer.frame = CGRectMake(0, 0, 60, 80); You can then add it as a sublayer to an existing CALayer...
The CAEmitterLayer class provides a particle emitter system for Core Animation. The particles are defined by instances of CAEmitterCell. The particles are drawn above the layer’s background color and border. var emitter = CAEmitterLayer() emitter.emitterPosition = CGPoin...
For example we will create view that contains emitter layer and animates particles. import QuartzCore class ConfettiView: UIView { // main emitter layer var emitter: CAEmitterLayer! // array of color to emit var colors: [UIColor]! // intensity of appearance var ...
You can add an image to a view's layer simply by using its contents property: myView.layer.contents = UIImage(named: "star")?.CGImage Note that the UIImage needs to be converted to a CGImage. If you wish to add the image in its own layer, you can do it like this: let myLayer = CA...
Basics There are a number of different transforms you can do on a layer, but the basic ones are translate (move) scale rotate To do transforms on a CALayer, you set the layer's transform property to a CATransform3D type. For example, to translate a layer, you would do something like this:...
CALayer property animations are enabled by default. When this is undesirable, they can be disabled as follows. Swift CATransaction.begin() CATransaction.setDisableActions(true) // change layer properties that you don't want to animate CATransaction.commit() Objective-C [CATransaction be...
layer.masksToBounds = true; layer.cornerRadius = 8;
You can use 5 properties on each layer to configure your shadows: shadowOffset - this property moves your shadow left/right or up/down self.layer.shadowOffset = CGSizeMake(-1, -1); // 1px left and up self.layer.shadowOffset = CGSizeMake(1, 1); // 1px down and right shadowColor - this s...

Page 1 of 1