Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有一个 CGImage 对象的 NSMutableArray。所有图像都有不同的尺寸(80x20 像素、200x200 像素、10x10 像素等...)我试图在 CALayer 中为它们制作动画,它的大小为 256x256 像素。动画有效,但我的 CGImages 被拉伸到 CALayer 的尺寸。如何防止我的 CGImages 被缩放?
谢谢你。
回答我自己的问题。我必须将图层的 contentsGravity 属性设置为 kCAGravityCenter,这样就成功了。contentsGravity 的默认值是 kCAGravityResize,它使事物被拉伸以填充图层的边界。