use layoutIfNeeded instead of layoutSubviews

via the docs:

You should not call this method directly. If you want to force a layout update, call the setNeedsLayout method instead to do so prior to the next drawing update. If you want to update the layout of your views immediately, call the layoutIfNeeded method.

In our case, we need to layout the views immmediately so we're using layoutIfNeeded