Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to copy constraints from one view to another?

Suppose I use Interface Builder to create UI in Storyboard with Auto Layout. Can I copy or move some constraints from one view to another?

like image 511
kelin Avatar asked Feb 20 '15 08:02

kelin


People also ask

How do you copy a constraint?

Select one or more bones, and select last the bone that has the constraints you want to copy. Press Ctrl + C to open the Copy Attributes menu, and select Copy Bone Constraints.

Can we add constraints to view?

Adding Your Own ConstraintsIf necessary we can create our own constraints on materialized view tables in addition to the ones Oracle may add. When the materialized view is in ON COMMIT mode these constraints effectively constrain the materialized view's base tables.

How do I delete a constraint in Swift?

Just select the view you want to remove a constraint from and open the size inspector. You should see a list of all the constraints. Select the one you want to delete, and press the delete key.


2 Answers

If you are using interface builder, some constraints will be automatic copied if you use the cmd-c or edit/copy: the ones that include the copying view hierarchy. Otherwise, no, you can't. Copy the whole view if you want to preserve the constraints.

like image 81
Display Name Avatar answered Sep 21 '22 18:09

Display Name


Here's my hack to get ALL the constraints to copy: I have a small view within my main view that I want to copy over to another view controller, in order to do this I copy over the entire main view into the new view controllers main view. I then drag my small view (on side hierarchy) into the main view of my new controller and then just deleted the old main view that I don't need. This way you keep all the constraints for the items within the small view.

Hope this helps :)

like image 27
Trianna Brannon Avatar answered Sep 22 '22 18:09

Trianna Brannon