【问题标题】:How to resize my view programmatically using autolayout如何使用自动布局以编程方式调整我的视图大小
【发布时间】:2015-02-19 12:04:24
【问题描述】:

我使用自动布局(xcode 6)在 xib 中设计了我的屏幕。我必须使用自动布局以编程方式重新设计屏幕。

我的屏幕上有 4 个水平视图。我必须隐藏第三个视图并使用自动布局将第四个视图移动到第三个视图的位置。

如何以编程方式更新约束。

【问题讨论】:

    标签: ios iphone cocoa-touch uiview autolayout


    【解决方案1】:

    您可以使用NSLayoutConstraint 并将适当的IBOutlet 分配给您的任何约束,然后在您想要更改视图大小的位置使用NSLayoutConstraintconstant 属性来更改值。 例如

    in your viewController.h
    @property (strong, nonatomic) IBOutlet NSLayoutConstraint *tempConstraint;
    some where in your viewController.m
    tempConstraint.constant = 50; // or what ever you want
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-02-04
      • 2014-12-21
      • 2012-08-20
      • 1970-01-01
      • 2011-12-29
      相关资源
      最近更新 更多