Re: Core Animation - Modifying CAConstraints
Re: Core Animation - Modifying CAConstraints
- Subject: Re: Core Animation - Modifying CAConstraints
- From: Nathan Vander Wilt <email@hidden>
- Date: Fri, 14 Mar 2008 00:13:30 -0500 (CDT)
> I have a situation where I want to re-order
> sublayers of a layer which
> are positioned using CAConstraints.
>
> Is this at all possible?
Not sure what you mean by "re-order", whether z-order
or sibling order, or if you mean re-layout? Using
CAConstraints will help with the last option.
> The constraints array property of a CALayer is
> declared as:
>
> @property(copy) NSArray *constraints;
>
> Which tells me that I can't modify the array in the
> object, but could
> modify the objects in the array. However,
> CAConstraint is completely
> private apart from initialisation methods.
I'm pretty sure you can also provide a new array of
constraints, eg: [sublayer setConstraints:[NSArray
array]]. The (copy) just means the array you pass will
be copied, there is no (readonly) flag on that.
But typically to add a constraint, just instantiate a
CAConstraint and add it to the sublayer with -[CALayer
addContraint:].
You'll also need to set the parent layer's
layoutManager property, to a
[CAConstraintLayoutManager layoutManager] (you can
also provide your own, without even using constraints,
but this one is meant to specifically deal with the
sublayers and their constraints).
You may occasionally need to explicitly call
-[CALayer setNeedsLayout] on the root layer, but it is
done automatically for some changes, IIRC.
Most of this is covered in:
http://developer.apple.com/documentation/Cocoa/Conceptual/CoreAnimation_guide/Articles/Layout.html,
which also has some sample code.
hope this helps,
-natevw
____________________________________________________________________________________
¡Capacidad ilimitada de almacenamiento en tu correo!
No te preocupes más por el espacio de tu cuenta con Correo Yahoo!:
http://correo.espanol.yahoo.com/
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden