0

is it possible to populate an equation in the "Constant" attribute located in the storyboard inspector , instead of a direct constant
and if so, can you write me an example of doing so?

tnx ;)

yehudshe
  • 45
  • 7
  • Possible duplicate of [How to update the constant height constraint of a UIView programmatically?](https://stackoverflow.com/questions/42669554/how-to-update-the-constant-height-constraint-of-a-uiview-programmatically) – João Rocha Jul 02 '19 at 17:37
  • Short answer: No. Long answer: What "equation" are you trying to use? It's possible that a combination of constraints with constants and/or multipliers can do what you need. – DonMag Jul 02 '19 at 17:38
  • thank for the respone , Basically the "equation" can be something like that : "SuperView.Width/3" for an "Equal Width" constraint . that means that the view, will be all ways third of its superview . I know that you can define it programatically, my question was about an more easy way to do it. how can a multipliers can help we get to the result of the view being alway 1/3 of its superview? , tnx – yehudshe Jul 03 '19 at 11:22

1 Answers1

0

For basic constraint "equations" you can often use the multiplier.

For your specific example, ""SuperView.Width/3" for an "Equal Width" constraint", set the view's width equal to the superView's width, then enter either 0.33333 or 1:3 as the multiplier:

enter image description here

Now your subview will always be 1/3rd the width of its superView.

DonMag
  • 69,424
  • 5
  • 50
  • 86