Difference between layoutSubviews () and viewWillLayoutSubviews ()


I understand that layoutSubviews() is a method in UIView and viewWillLayoutSubviews() is a method in UIViewController, they are both used to adjust the position of the subviews when the bounds/frame changes, but I'm not exactly sure the difference between them and when to use them. Could someone please enlighten me?

There is no effective difference. One (layoutSubviews) is a message the runtime sends to the view, the other (viewWillLayoutSubviews) is a message the runtime sends to the view controller. The message to the view controller tells the view controller that its view is about to receive the view message! That's all. They go together.