ios - 如何使用自动布局设置按钮宽度并针对 iPhone 6 plus 进行调整?

标签 ios xcode swift ios8 iphone-6-plus

我正在学习 Swift 并尝试做一个测试计算器项目来感受 Xcode 6 和 iOS 8。

我已将 Storyboard设置为 wCompact,hAny。这是我的观点:

enter image description here

  • AC 按钮的左内边距为 16。
  • 其余按钮的左内边距为 8。因此每个按钮之间的距离为 8。
  • 所有按钮的顶部内边距都是 8。
  • 所有按钮的高度都是 30。

我已经将每个按钮的宽度设置如下:

enter image description here

我计算出的常数为

constant = 16(AC left padding) + 8(distance between AC and "(") + 8(distance between "(" and ")") + 8(distance between "(" and Adv) + 16(Adv right padding)
constant = 56

and multiplier = 4(total number of buttons)

这样我试图保持所有四个按钮的宽度相同。它适用于 iPhone 4/4S、5/5S 和 6。

enter image description here

但是当我在 iPhone 6 上运行时,按钮会像这样向右推:

enter image description here

这是否与 iPhone 6 plus 的不同 ppi、401 或 iPhone 6 plus 中发生的 UI View 下采样有关?

任何帮助都会很棒。

更新 1:回应@Mundi 发布的回答

我曾尝试向“Adv”按钮添加左填充,但随后按钮被推向左侧并与“)”按钮重叠。然后它看起来像下面这样:

enter image description here

最佳答案

在最右边的按钮右侧添加一个最小间距限制,或者与上面的字段右对齐。

关于ios - 如何使用自动布局设置按钮宽度并针对 iPhone 6 plus 进行调整?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26381427/

相关文章:

ios - Xcode 中的帧捕获失败

swift - 创建多行文本并将其写入文本文件 (CSV)?

ios - UIActivityViewController 没有将换行符传递给某些事件

ios - 将文本从 UIAlertView 文本字段传递到自定义单元格标签

ios - Apple Developer Enterprise Program 应用没有图标

ios - tableview 重复单元格向下滚动

ios - 我应该使用 UITableView 节标题还是静态 UITableViewCell?

ios imagePickerController :didFinishPickingMediaWithInfo: not called after stopVideoCapture

ios - 以编程方式为新 CollectionView 添加 TabItem

ios - 我在哪里可以下载适用于 XCode 的 IOS DeviceSupport 16A5357B?