Reputation: 999
I am building a UI where the background color of the main view is black and the background color of some UIView elements within the View are white. The colors get displayed properly when there is not UI constraint for the UIView elements. However, when I add any constraint to the UIView elements, the white background seems to get transparent. I assume that it is still there, since UI constraints of other elements in relative to this UIView element are still on their correct place.
This is the structure of my UI (without UI constraints):
And this is how it looks like in simulator (iPhone XR 12.2):
Now I add the following UI constraints to the UIView element view_config
When I run the app in simulator again, now the background color of view_config is transparent.
Upvotes: 1
Views: 710
Reputation: 91
is your super view have clear color then change it to black color it will fix your problem
Upvotes: 0
Reputation: 999
Adding a height constraint solved the problem.
Even better than a static height constraint would be a relative constraint so that the height of element is calculated implicitly.
Upvotes: 1