Re: center-y constant animation won't animate
Re: center-y constant animation won't animate
- Subject: Re: center-y constant animation won't animate
- From: Ken Thomases <email@hidden>
- Date: Mon, 04 Aug 2014 18:17:45 -0500
On Aug 4, 2014, at 6:10 PM, Rick Mann <email@hidden> wrote:
> I'm setting the constant of a center-y-in-container constraint in a [UIView animateWith…] block, but it doesn't animate; it just jumps to the offset location. Any idea what I might be doing wrong? The code is pretty straightforward…
>
> https://pastee.org/edgsf
>
> I tried calling -animateWithDuration directly, and enqueueing it on the main queue (as seen here). Same result.
>
> Any help would be much appreciated.
There are two approaches, but I don't know if the second applies on iOS.
First, the way you did it, is to just set the constraint constant. However, you then have to force layout. The constraint itself is not being animated. The changes to the frames that are done within the animation group are. So, you need to call [self layoutIfNeeded] within the animation group.
The second way is to animate the constraint itself. In this case, you change the constant on the constraint's animator proxy, not directly on the constraint. So, you'd do self.logoVerticalConstraint.animator.constant = 100.
Cheers,
Ken
_______________________________________________
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