JustWork JustWork - 26 days ago 39x
iOS Question

Xcode 8 UIButtons with constraints not showing up

Everything used to work great until yesterday I updated Xcode to version 8.

If I don't use any constraints, I can see the buttons but when I apply constraint(s) to the buttons they disappear, no matter what or how many constraints (height, vertical spacing, trailing etc...) I apply.

When I tap buttons, they act normal (events are always sent so I assume they are actually located there(?)). I tried changing text color, background color, (even adding a new UIButton) but ended with no luck. I can't see the buttons. When I change the background color of

Centered View
I can see this change on the app. The weirdest part is when I click
Debug View Hierarchy
on Xcode to see what is going on, everything looks fine there; I can see all buttons located as I expect.


Testing the app both on iPhone 5 (iOS 9.3.5) and iPhone 6 (iOS 10).

I am using Swift 2.3, iOS 10 and Xcode 8.

Is this a bug on Xcode 8? How to resolve this issue?


I just realised same constraint problem occurs on UILabel and UIImageView too. They look fine without constraint but when I add any constraint they disappear.


I was missing the point of setting UIButton class to my custom class. I checked my custom class and have seen that I set corner radius on awakeFromNib() method. I called layoutIfNeeded() before I set corner radius which was the solution in my case.