iOS Simulator button not centered

后端 未结 2 984
遥遥无期
遥遥无期 2021-01-15 15:48

I\'m following a tutorial to make a very simple game, yet I\'ve run into a problem I can\'t figure out. When I center my button on the editor screen it all looks fine, but t

2条回答
  •  走了就别回头了
    2021-01-15 16:36

    You need to use autolayout to set some constraints on the button. If you don't use autolayout, the layout just uses the raw X and Y values. So in landscape, the heights of the screen are the same, but the widths are different. Your button lays out at the same X value on both screens, so one will be centered and one won't be.

    Check out this tutorial for more info on layout constraints.

提交回复
热议问题