我有一个功能齐全的应用程序,我正在 Interface Builder 中创建一个带有按钮和标签的新 View Controller 。我已经在 Interface Builder 中布置了所有内容,并使用 AutoLayout
确保每个组件都就位。它在 iPhone 5s 上运行良好,但在 iPhone 6 和 6 Plus 上,我的 UIButton
没有调整其高度以适应更大的屏幕。
截图有助于更好地理解这一点。
iPhone 5s
iPhone 6 Plus
Update Me 文本是一个 UILabel
。 Basic to the bottom PRO Unlimited 是一个 UILabel
。这些按钮是单独的 UIButton
。恢复购买是一个 UIButton
,底部的最终文本是一个 UILabel
。
我的约束条件是:
基本标签
SuperView 的尾随空格
引导空间到Superview
恢复购买的底部空间 UIButton
UpdateMe UILabel
的顶部空间
购买 100 个 UIButton
引导空间到Superview
Trailing Space to Buy Unlimited UIButton
顶部空间到顶部布局
恢复购买的底部空间 UIButton
等宽无限买 UIButton
无限购买 UIButton
SuperView 的尾随空格
领空买100
顶部空间到顶部布局
恢复购买的底部空间 UIButton
等宽买100个
恢复购买UIButton
SuperView 的尾随空格
引导空间到Superview
顶部空间基础 UILabel
底部空间到一次性 UILabel
无限购买空间
顶层空间买100
在 iPhone 5s 上,恢复购买 UIButton
的宽度为 268,高度为 30。
在 iPhone 6 Plus 上,Restore Purchases UIButton
的宽度为 382,高度为 198,很明显这会占用大量空间,从而导致 UIButton
不增加。
我想要实现的是,每个组件都在原位,但在 iPhone 6 Plus 上,有 Buy 100 和 Buy Unlimited UIButton
以增加高度宽度保持不变。
任何关于这方面的指导将不胜感激!
最佳答案
在这里您可以为您的按钮添加纵横比约束。
关于ios - UIButton 高度增加大小使用 AutoLayout 与不同的设备,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29252535/