简体   繁体   English

从iPhone 4s到iPhone 6+的自适应布局来隔开布局元素

[英]Spacing layout elements with adaptive layout from iPhone 4s to iPhone 6+

I'm attempting to build a view (iPhone only, portrait view only) using adaptive layout. 我正在尝试使用自适应布局构建视图(仅iPhone,仅纵向视图)。 It should all be on a single screen (ideally no scrolling). 它应该全部在一个屏幕上(理想情况下不滚动)。 I've managed to get it working (reasonably) for the iPhone 5 - 6+. 我设法使其(合理地)适用于iPhone 5-6+。 However, my issue comes with the 4s. 但是,我的问题与4s有关。

在此处输入图片说明

I'd like, on the iPhone 4s to have the center image go away, which I thought I could use size classes, but it doesn't seem so for the various iPhones in portrait mode (only if I switch orientation). 我想在iPhone 4s上消除中心图像,我以为我可以使用尺寸类别,但是对于纵向模式下的各种iPhone来说似乎不是这样(仅当我切换方向时)。

Additionally, I'd like there to be more padding between all the elements on the 6+ while spacing remains the same on the 5 and 6. 此外,我希望6+上的所有元素之间都有更多填充,而5和6上的间距保持相同。

No matter what sizes all iPhone in portrait mode is regular height compact width so size class won't help you here. 不管纵向模式下所有iPhone的尺寸是常规高度紧凑宽度,所以尺寸级别在这里都无法为您提供帮助。

To change padding constraint 更改填充约束

  1. make the ones you want to change IBOutlets 使您想要更改的IBOutlets

  2. and in viewDidLoad for example change the NSLayoutConstraint 's constant value based on screen height. 并在viewDidLoad中例如根据屏幕高度更改NSLayoutConstraintconstant量值。

For iPhone 4S you can 对于iPhone 4S,您可以

  1. hide the center imageView 隐藏中心imageView

  2. deactivateConstraints all it's constraints deactivate约束所有约束

  3. and activate new constraint between the view above imageView and below imageView if needed 并在需要时在imageView上方和imageView下方的视图之间激活新的约束

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM