How do I update a constraint on my CALayer?
How do I update a constraint on my CALayer?
- Subject: How do I update a constraint on my CALayer?
- From: Austin Grigg <email@hidden>
- Date: Fri, 4 Sep 2009 19:29:56 -0400
I have a CATextLayer that I want to be able to vertically align within
my view. I can set a constraint to align it to the top of the view, to
the middle, or to the bottom; but I want to be able to allow the user
to change this on the fly. When I set up my CATextLayer, I use this
constraint to align it in the middle:
[textLayer addConstraint: [CAConstraint
constraintWithAttribute:kCAConstraintMidY
relativeTo:@"superlayer"
attribute:kCAConstraintMidY]];
This works fine, but if I want to update the layer to align it to the
top of the view I try:
[textLayer addConstraint: [CAConstraint
constraintWithAttribute:kCAConstraintMaxY
relativeTo:@"superlayer"
attribute:kCAConstraintMaxY]];
When I add the new constraint it doesn't get aligned to the top, but
goes past the top of the view where you can only see part of it. It
looks like it is trying to apply both of the constraints. There is no
removeConstraint and the same thing seems to happen if I define a
CAConstraint variable on my class and just update that variable after
adding it to the CATextLayer. Do I need to recreate the CATextLayer
every time?
_______________________________________________
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