Search code examples
swiftxcodemacosxcode10

How to center a label so that it appears centred on all simulators on xcode 10?


I'm trying to center a label on a basic app in swift so that it is centered on all simulators using xcode 10. I know on previous version you could uncheck Use size classes but that doesn't show on xcode 10. I've also tried unchecking Use trait variations but the label still ends up being uncentred on some simulators.

enter image description here

enter image description here

Any ideas how I can do this on xcode10? Any help would be great


Solution

  • You need 2 constraints

    1- Add top constraint by ctrl-drag from the label to it's superView and select top

    2- Add centerX constraint as above