CALayer Position Contents to Bottom Left
Posted
by
Louis
on Stack Overflow
See other posts from Stack Overflow
or by Louis
Published on 2012-04-05T21:49:01Z
Indexed on
2012/04/06
5:29 UTC
Read the original article
Hit count: 134
I am attempting to draw an image onto a CALayer. I only need an image, so I have created my later as follows:
CALayer *layer = [CALayer layer];
I add my image as follows:
NSImage *img = [[NSImage alloc] initWithContentsOfFile:@"path/to/img.png"];
[layer setContents:img];
This works, however it draws my images to fill the entire parent frame (stretching my image in the process).
Reading the docs, I found the following:
[layer setContentsGravity:@"kCAGravityBottomLeft"];
I am attempting to draw my image in the bottom left of the parent frame, however no matter what I do it draws my icon in the bottom center. Is there anyway to specify the bottom left?
© Stack Overflow or respective owner