我在 ios 的约束部分方面真的很弱.我浏览了许多参考链接,如下所示,但仍然无法解决我的问题.
如果条件在第 1 步时 UIView2 失败,第 2 步和第 3 步 应该可见,并且它的位置也应该改变,如 condition1.png 所示
如果条件通过 UIView2 与 step1,则 step 2 和 step3 应该不可见 如 condition1.png 所示
请提供如何实现上述场景的步骤.我试过这样做,但如果为 UIView1 设置约束,高度保持不变并且在运行时不会改变.
只要把两个UIView的高度做出口,用常量属性来改变高度约束,比如...
如果条件失败{heightconstOfView1.constant = 0}别的{heightconstOfView2.constant = 0}
I'm really very weak in constraints part of ios. I have gone through many reference link as shown below but still not able solve my issue.
Hide autolayout UIView : How to get existing NSLayoutConstraint to update this one
In case , i need to change the y-axis of UIView2 based on some condition. The storyboard.png shows the layout.
If condition fails UIView2 with step1, step 2 and step3 should be visible and it's position should also change as shown in condition1.png
If condition pass UIView2 with step1, step 2 and step3 should not be visible as shown in condition1.png
Please provide me steps for how to achieve the above scenario. I tried it doing but if set the constraint for UIView1 the height remains same and does not change at runtime.
just make the outlet of height of both UIView and use constant property to change the height constraints like...
if conditionfails{
heightconstOfView1.constant = 0
}
else{
heightconstOfView2.constant = 0
}
这篇关于在运行时快速更改约束的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!