CAScrollLayer "Contents" Size
Scott Stevenson
sstevenson at mac.com
Wed Mar 12 15:15:57 PDT 2008
On Mar 12, 2008, at 5:06 AM, Matt James wrote:
> As a side note, is there any way to setup a layer so that it grows its
> bounds based on sublayers added? It seems silly to have all this
> code to
> constantly update the bounds so that references to height and width
> of a
> given layer are accurate for what I want.
I actually don't think you want to keep growing the parent layer like
that. It doesn't really have any practical benefit and it eats up
resources. The parent layer generally only needs to be as big as the
on-screen display area.
> I'm thinking along the lines of contentsGravity, but for sublayers.
If you want to align sublayers along particular edges of the
superlayer, you can use the "autoresizingMask", which works like
springs and struts in NSView. So to keep a sublayer in the lower-left
corner of the superlayer:
sublayer.autoresizingMask = ( kCALayerMinXMargin |
kCALayerMinYMargin );
If you want to position a collection of layers relative to each other
(such as a grid), you can use CAConstraintLayoutManager.
- Scott
More information about the MacOSX-dev
mailing list