Moving content of UITableViewCell on tap

2019-06-05 09:40发布

问题:

If anyone have Google+ App can certainly understand what I'm trying to implement.
(explained here: UIViewController Containment with animation like Google+)

I think it has something related with the new effect in iOS 7 Calendar App.
(explained here: Recreating iOS 7 Calendar UIView Animation)

-

This is a common animation effect that I'm seeing in many apps these days.

Months ago, the fellow Rob tried to help me with this his answer:

Now I was trying to implement it but there's a problem. Images explains better:


INITIAL STATE



WHAT HAPPEN WITH CURRENT IMPLEMENTATION



WHAT SHOULD HAPPEN

I've created a super simple project that shows the implementation (few lines).

Can someone help me to find where's the problem?

REPO: https://github.com/socksz/MovingTableViewCellContent

回答1:

The problem is that you're trying to change the view's frame with Auto Layout on. You can't do that. The Auto Layout system will overwrite your changes. Try turning off Auto Layout in your storyboard and you'll see that it works.

So your options are:

  1. Don't use Auto Layout
  2. Use/manipulate constraints instead of frames.

For (2) you can just go into the storyboard and set up width and height constraints on the container view and it will work. If fixed size isn't the exact behavior you want, you'll need to be more explicit in your requirements.

The default constraints you're getting now are attached to the parent view and aren't getting carried along for the ride when you move the view to a new parent.