Creating a CALayer

suggest change

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:

Swift:

existingLayer.addSublayer(layer)

Objective-C:

[existingLayer addSublayer:layer];

Note:

To do this you need to include the QuartzCore framework.

Swift:

@import QuartzCore

Objective-C

#import <QuartzCore/QuartzCore.h>

Feedback about page:

Feedback:
Optional: your email if you want me to get back to you:



Table Of Contents