【问题标题】:How to convert NSlayout constraint to integer?如何将 NSlayout 约束转换为整数?
【发布时间】:2021-09-22 06:46:16
【问题描述】:

我想在 nslayoutconstraint 中添加 20 个常量值,我该怎么做??

Let moduleConstraint = module.bottomAnchor.constraint(equalTo:mainScroll.safeAreaLayoutGuide.bottomAnchor)

【问题讨论】:

    标签: ios swift anchor nslayoutconstraint


    【解决方案1】:

    你可以试试

    moduleConstraint.constant += 20
    view.layoutIfNeeded() // refresh the layout 
    

    【讨论】:

    • 就我而言,我使用的是滚动视图,我应该减去 -=20 否则它将把集合视图裁剪 20,无论如何,因为我没有提供任何上下文,所以你的答案是 100% 正确的。
    猜你喜欢
    • 1970-01-01
    • 2020-10-26
    • 2020-11-15
    • 2020-11-08
    • 1970-01-01
    • 2021-06-08
    • 1970-01-01
    • 1970-01-01
    • 2013-07-24
    相关资源
    最近更新 更多