I’ve just started working with constraints, and I’m finding it onerous to have to set both the location and the size of a UIView using constraints–four constraints seems excessive. (I don’t doubt that it’s possible to do with fewer constraints; I’m just still working with a very basic understanding!) Is it possible to set the size of a UIView, therefore, not using constraints, but then set the location using constraints? The only non-constraint ways I know to set size also involve setting origin.
I’ve just started working with constraints, and I’m finding it onerous to have to
Share
If you are using AutoLayout to manage view position and size it’s not advised to adjust a view’s frame. Most of the time this won’t work anyway.
But even AutoLayout needs to know about size and position. So you’ll always end up having to specify both. If like you ask it would be possible to set less than 4 constraints (by not specifying it’s position for example), AutoLayout would not know where to show the view.
What is it you find hard about having to specify 4 constraints? This is done automatically for you in your XIB/Storyboard file. If you are writing everything in code checkout the convenience ASCII-art-format strings which lets you specify position and sizing using a ‘visual’ string representation.