Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CGImage gets stretched in CALayer

I have an NSMutableArray of CGImage objects. All the images have different dimensions ( 80x20 px, 200x200 px, 10x10 px, etc...) I'm trying to animate these in CALayer which has 256x256 pixels size. The animation works, but my CGImages get stretched to the dimensions of the CALayer. How could I prevent my CGImages from getting scaled?

thank you.

like image 974
PrimeSeventyThree Avatar asked Jun 10 '11 12:06

PrimeSeventyThree


1 Answers

To answer my own question. I had to set my layer's contentsGravity property to kCAGravityCenter and that did the trick. The default value of contentsGravity is kCAGravityResize which makes things stretched to fill in layer's bounds.

like image 154
PrimeSeventyThree Avatar answered Oct 24 '22 16:10

PrimeSeventyThree