【问题标题】:Fixed space between objects in both orientations两个方向上的对象之间的固定空间
【发布时间】:2012-07-18 14:18:03
【问题描述】:

我正在使用 AutoresizingMask 以编程方式定义相对位置。我几乎一切正常,但我不知道如何在两个元素之间保持相同的分隔(UIButton、UILabel 被 20px 分隔) 这就是我所拥有的:

UIButton,定位在(100, 100),大小:60x30,autoresizingMask=UIViewAutoresizingFlexibleRightMargin | UIViewAutoresizingFlexibleLeftMargin

UILabel,定位在(180,100),大小:50x50,autoresizingMask=UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleLeftMargin

我的问题是,当方向改变时,我无法在这两个元素之间保持 20px 的边距。

【问题讨论】:

    标签: ios interface-builder autoresizingmask


    【解决方案1】:

    我经常发现在改变方向时我需要对我的 UI 做更多的“调整”,而不是自动发生的事情。

    您可以将此例程添加到您的控制器,并以您喜欢的方式微调您的 UI:

    - (void) didRotateFromInterfaceOrientation:(UIInterfaceOrientation) o {
       -- Set the label to be 20px to the right of your button here
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2010-10-04
      • 1970-01-01
      • 2015-04-29
      • 1970-01-01
      • 1970-01-01
      • 2020-10-23
      相关资源
      最近更新 更多