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 contents property of calayer object, doing may not yield best results. instead of using image object, can use layercontentsforcontentsscale: 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 supports kcagravityresize, kcagravityresizeaspect, , kcagravityresizeaspectfill modes.


Comments

Popular posts from this blog

php - SPIP: From Tag directly to an article -

jquery - isAjaxRequest always return false -

ruby on rails - In a controller spec, how to find a specific tag in the generated view? -