ios - UIButton 高度增加大小使用 AutoLayout 与不同的设备

标签 ios objective-c iphone xcode autolayout

我有一个功能齐全的应用程序,我正在 Interface Builder 中创建一个带有按钮和标签的新 View Controller 。我已经在 Interface Builder 中布置了所有内容,并使用 AutoLayout 确保每个组件都就位。它在 iPhone 5s 上运行良好,但在 iPhone 6 和 6 Plus 上,我的 UIButton 没有调整其高度以适应更大的屏幕。

截图有助于更好地理解这一点。

iPhone 5s enter image description here

iPhone 6 Plus enter image description here

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 以增加高度宽度保持不变。

任何关于这方面的指导将不胜感激!

最佳答案

在这里您可以为您的按钮添加纵横比约束。

enter image description here

关于ios - UIButton 高度增加大小使用 AutoLayout 与不同的设备,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29252535/

相关文章:

ios - MWPhotoBrowser 不显示导航标题中单个图像的显示图像名称

ios - UIImage,检查是否包含图像

ios - 在 uicollectionview 中选择时如何让 Quicklook 在索引处加载图像

iphone - iOS 上 PayPal 的 MPL 库的初始化实际上是一个阻塞过程吗?

iphone - 通过 initWithFrame 添加 subview 。 UINavigationBar 大小

ios - 如何在 Xcode 中创建机器人?获取 "Creating a bot requires a project that is under source control."

objective-c - 从 subview 添加 View 到父 View

ios - 在 View 中执行页面跳转是否违背MVC架构?

iphone - 刷新 iPhone 上的 TextView 滚动位置

iphone - 使用自签名 SSL 证书连接到 HTTPS