Why do I see a crash when using most content constants in NSView?

I have a subclass of NSView, and the following is set in the initWithFrame am method:

self.wantsLayer = YES;
self.layer.contents = [NSImage imageNamed:@"sprite-sheet"];
self.layer.contentsGravity = kCAGravityLeft;

and when I run it, I get the expected visual results ... and crash with the following log:

** Misuse of NSImage and CALayer. contentsGravity remains. It must be one of the resize, resizeAspect, or resizeAspectFill parameters.

Why? There is no indication in the documents that other values ​​should not be used.

+4
source share
1 answer

Actually, the behavior you see is in the documentation. This is simple in the NSImage documentation, not the CALayer documentation (highlighted by me):

CALayer

NSImage contents CALayer, . layerContentsForContentsScale: , . , . NSImage kCAGravityResize, kCAGravityResizeAspect kCAGravityResizeAspectFill.

+6

Source: https://habr.com/ru/post/1531053/


All Articles