Why does layoutSubviews() not update view presentation after view frame changing?

Hi!

  1. I create a view hierarchy which has container view and internalView in it. internalView is centered by constraints in container view.
  2. I change center (and therefore the frame): internalView.center = CGPoint(x: internalView.center.x + 50, y: internalView.center.y) and internalView is moved! (unexpected)
  3. Then if I do containerView.setNeedsLayout() - internalView is placed back to the center of containerView view as constraints demand (expected) but if I do containerView.layoutSubviews() - the same doesn’t happen (unexpected).

Here is repository with source code to test this.

So the questions are

  1. Why internalView is moved with center changing? I supposed that it shouldn’t happen since nearest automatic layout pass should instantaneously place internalView back to the center.
  2. Ok. For some reason view is not placed back automatically and it is placed back by setNeedsLayout(). But why layoutSubviews() doesn’t do the same job? (My suggestion was that setNeedsLayout() set some flag that indicating that layoutSubviews() must be called at next layout pass and layoutSubviews() is the method which eventually do the job of layout anyway.)

Thanks a lot for any help.