ios - 自动布局中的 UIButton 动态宽度

标签 ios uibutton autolayout

大家好,我有一个。 当我删除或隐藏一个按钮时,我在 Controller 中有两个按钮我想要另一个按钮根据宽度增加大小。 我在这里使用自动布局,所以请相应地发布您的答案

enter image description here enter image description here

看到上图,当我隐藏按钮时,其他按钮应该随尺寸调整。

最佳答案

  1. 像第一个屏幕截图一样设置创建布局所需的所有约束
  2. 在 IB 中,您选择“时间按钮”和“现金支付”按钮并添加约束以对齐它们的后缘
  3. 选择这个新的“trailing-edges-constraint”并将其优先级设置为高 (750)
  4. (对“立即付款”按钮重复步骤 1-3,但这次与前缘对齐)

就是这样!

关于ios - 自动布局中的 UIButton 动态宽度,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33568292/

相关文章:

ios - 如何使用自动布局在 super View 之间制作动画?

ios - 用例有两种方式进行相同的操作

objective-c - 将 char 数组保存到 iPhone

ios - iPhone : Multiple touches on a UIButton are not recognized

ios - UIButton touchDragInside 不起作用

ios - Swift - 减少 UICollectionViewCell 之间的间隙

ios - 如何使用约束使我们的 Freedom View Controller 可滚动?

ios - Apple 的 CurrentAddress 示例中的 MKReverseGeocoder autorelease/release 问题

objective-c - 架构 armv7 的 106 个重复符号

ios - Swift - 在横向时创建 UIButton