Entity Injection

I built a test project to show what the goal is compared to what I'm doing right now. The gif on the left shows that I want the final look. It is built with a single traditional hierarchy of views. I need to achieve this, with a pink view inline / containing view . My attempts so far have led me to the gif on the right.

How the pink image grows is perhaps an important detail: the blue subtask changes its height, and the whole device gets a new own size of its own due to all the associated vertical restrictions. As you would expect, this is a simplification of my actual application, but I think it has all the important bits.

Ideal visual outcome: Smooth animation of both the contained view and it's siblings in the containing context As is: The inner parts of the contained view animate well, but the sibling view does not animate.

The main things that I see are strange:

  • / "" .
  • , , , : Before and after the animation, the frame has the same origin

gif. "" , "" translatesAutoresizingMaskIntoConstraints false .

Xcode storyboard showing embedded view setup and constraints

: ** , (), ? **

: , Containment View Controller Containment, , Storyboard, . , , , .

: Bounty 100 , . github repo. !

+4
1

InnerViewController .

var isCollapsed = false {
    didSet {
        let factor:CGFloat = isCollapsed ? 1.5 : 0.66
        let existing = innerViewHeightConstraint.constant
        UIView.animate(withDuration: 1.0) {
            self.innerViewHeightConstraint.constant = existing * factor
            self.view.layoutIfNeeded()
            self.parent?.view.layoutIfNeeded()
        }
    }
}

self.parent?.view.layoutIfNeeded(), , .

+1

Source: https://habr.com/ru/post/1671312/


All Articles