FROM : Scott Stevenson
DATE : Wed Mar 12 23:15:57 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
DATE : Wed Mar 12 23:15:57 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
| Related mails | Author | Date |
|---|---|---|
| Matt James | Mar 11, 17:18 | |
| Scott Stevenson | Mar 11, 23:25 | |
| Matt James | Mar 12, 02:34 | |
| Scott Stevenson | Mar 12, 06:07 | |
| Matt James | Mar 12, 12:56 | |
| Matt James | Mar 12, 13:06 | |
| Scott Stevenson | Mar 12, 23:15 | |
| Matt James | Mar 13, 02:15 | |
| Scott Stevenson | Mar 13, 04:08 | |
| Scott Stevenson | Mar 13, 04:11 |






Cocoa mail archive

