I want to change the relation of a constraint programmatically that is why I create a new one and replace the old one with it. I have an IBOutlet of my constraint which I want to change. As because I am using multi-os-engine my code for updating the constraint looks a little bit different to normal objectiv-c or swift.
setBasketTopConstraint(
NSLayoutConstraint.constraintWithItemAttributeRelatedByToItemAttributeMultiplierConstant(
basketTopConstraint().firstItem(),
basketTopConstraint().firstAttribute(),
NSLayoutRelation.LessThanOrEqual,
basketTopConstraint().secondItem(),
basketTopConstraint().secondAttribute(),
basketTopConstraint().multiplier(),
basketTopConstraint().constant()
)
);
My problem is, that I can't see any effect from changing the constraint. It seems like I need to refresh my view somehow. I called view().setNeedsLayout()
and view().layoutIfNeeded()
but with no success.
Any advice?
You need to ensure that you:
layoutIfNeeded()
您是否尝试添加代码以更改视图将布局子视图的约束?
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.