I have following view hierarchy:
- Root View
- Child View
The root's height and width have been stretched by constraints (Top, Bottom, Leading, Trailing) and should be about 500. The height of the child is set by constraints too, so it should also equal 500.
Everything looks fine visually, but when I access the frame.bounds.height of the child it returns me the height of the whole screen, rather than the estimated 500. Even worse, when I access the frame.bounds.height on the Rootview it returns me 0 because I have set the frame to .Zero.
My question now is, how can I get the width and height from a view, that has been stretched out by constraints? It seems to me that .frame.bounds does not work with autolayout.
Showcase:
print("collectionView height: ", String(describing: collectionView.frame.height) )
cv height: 0.0
CollectionView is the brown view:
My main objective was to make a cell as big as the brown collectionView. But this failed because I could not get the width of the dynamically sized collectionView.