xcodeautolayoutxcode8

Xcode 8.3.3 autolayout - view is disappearing runtime when setting constraints


I'm trying to make a divider, so what I do is:

1) Make a new View

2) Change the background to the color I want the divider to be

3) Control click and center it horizontally on a label on top of it

4) Compile, my view is gone.

5) Remove constraints, compile, my view is there.

6) Add left and right constraint for autosize, compile, view is gone.


It also states that the height of my view is ambiguous.

How can the view be gone by merely constraining it?

Screenshot: enter image description here


Solution

  • here is my output I tried in swift using Xcode and tried setting constraints as I do

    My added view

    Constraints of view

    Simulator output

    Try giving height and width or aspect ratio to vary according to size of screen