开发者

CGImage gets stretched in CALayer

开发者 https://www.devze.com 2023-03-12 04:31 出处:网络
I have an NSMutableArray of CGImage objects. All the images have different dimensions ( 80x20 px, 200x200 px, 10x10 px, etc...)

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.


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消