iOS自动布局动态前导和尾随约束

4
我们如何设置动态的前导和尾随约束,就像我们通过屏幕尺寸的百分比提供动态宽度和高度一样。
2个回答

1

尝试这个
在你的视图控制器中添加以下属性

@property (strong, nonatomic) IBOutlet NSLayoutConstraint *cnstViewLeading;
@property (strong, nonatomic) IBOutlet NSLayoutConstraint *cnstViewTrailing;

然后按照你的前导和尾随设置 Outlet,例如......

并且

使用方法如下:
//    replace value whatever you want with 0
    self.cnstViewLeading.constant = 0;
    self.cnstViewTrailing.constant = 0;

0

您可以创建NSLayoutConstraint的输出口,并根据需要更新其常量。在更新其常量后,您需要调用view.layoutIfNeeded()。 或者,您也可以使用乘数进行百分比布局。


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接