Re: Conserve size of UIButton after CATrasform3DScale
Re: Conserve size of UIButton after CATrasform3DScale
- Subject: Re: Conserve size of UIButton after CATrasform3DScale
- From: Matt Neuburg <email@hidden>
- Date: Sun, 07 Apr 2013 15:50:44 -0700
> Date: Sun, 07 Apr 2013 02:09:48 +0200
> From: Kévin Vavelin <email@hidden>
> Subject: Conserve size of UIButton after CATrasform3DScale
>
> Hi there,
>
> I have an animation in my app and I want to know how I can set the frame of my UIButton as the same I have after my CATransform3DScale and how can I do that with my auto layout cause I can't change my width size with auto layout enable. The only way is to remove the layout constraint or change the constant programmatically but if we have something better to do…
We don't. Who lives by the constraint, dies by the constraint. You can take your view out of the autolayout system by setting its translatesAutoresizingMaskIntoConstraints to YES, or you must adjust your constraints to match the change you made in your animation. Otherwise, layout will undo the transform the next time it occurs (or will even crash your app as you try to perform the animation). Typically this will involve changing the constant of the constraint. The most elegant solution, however (if you can call it elegant), is for your animation to animate the constraints constant to begin with. See my essay on Stack Overflow here:
http://stackoverflow.com/a/14105757/341994
Here's where I deal with animation vs. autolayout in my book:
http://www.apeth.com/iOSBook/ch17.html#_animation_and_autolayout
There's more discussion on transforms vs. autolayout earlier in the book:
http://www.apeth.com/iOSBook/ch14.html#_autolayout_and_view_transforms
I regard this entire situation as a huge bug (and I have submitted a bug report on it). Autolayout works by changing the *frame* of a view at layout time. But every beginner knows that once you've applied a transform, the frame is wrong and must not be touched; you must use the bounds and center instead - and that's what autolayout should do. Every workaround is messy in one way or another. It's as if the autolayout people forgot to consult the animation people when they came slashing through the forest with their bulldozers. m.
--
matt neuburg, phd = email@hidden, http://www.apeth.net/matt/
pantes anthropoi tou eidenai oregontai phusei
Programming iOS 6! http://shop.oreilly.com/product/0636920029717.do
RubyFrontier! http://www.apeth.com/RubyFrontierDocs/default.html
TidBITS, Mac news and reviews since 1990, http://www.tidbits.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