osx - Why am I seeing a crash when using most contentsGravity constants in NSView? -
i have nsview subclass , in initwithframe method setting following:
self.wantslayer = yes; self.layer.contents = [nsimage imagenamed:@"sprite-sheet"]; self.layer.contentsgravity = kcagravityleft; and when run it, expected visual results... , crash following log:
** misuse of nsimage , calayer. contentsgravity left. should 1 of resize, resizeaspect, or resizeaspectfill.
why? there's no indication in docs other values should not used.
actually, behavior seeing in documentation. it's in nsimage documentation , not calayer documentation (emphasis me):
using images calayer objects
although can assign nsimage object directly
contentsproperty of calayer object, doing may not yield best results. instead of using image object, can uselayercontentsforcontentsscale:method obtain object can use layer’s contents. method creates image suited use contents of layer , supports of layer’s gravity modes. by contrast, nsimage class supportskcagravityresize,kcagravityresizeaspect, ,kcagravityresizeaspectfillmodes.
Comments
Post a Comment