How do I position views in Interface Builder for both 3.5” and 4” Retina?

前端 未结 3 1262
遇见更好的自我
遇见更好的自我 2021-01-31 23:45

I want to position a UIView so it appears in the centre on both 3.5” and 4” Retina screens. What is the best way to do this? If I turn off all the Autosizing bars I would expect

3条回答
  •  误落风尘
    2021-02-01 00:02

    To center view in its parent (container) view in IB with autolayout:

    • Select you view
    • go to menu and select Editor->Align->Horizontal/Vertical Center in Container option

    However you can use autolayout only if you support iOS 6 and later, if you target earlier OS versions you'll have to use other approaches (e.g. setting centring view with code as Eric suggested)

提交回复
热议问题