Reputation: 2284
I have a complex constraints layout in one project I have copied and pasted to another. Its job in this second project is identical in all respects except that I need to replace a UIImageView
with a UIButton
. Deleting the UIImageView
will also remove the constraints I worked hard to balance correctly in the first place. Is there better solution to this problem than deleting and painstakingly recreating the constraints?
Thank you for reading.
Upvotes: 1
Views: 247
Reputation: 15639
Everything is perfect in your copying view. Do the following steps to get an easy solution
- Drag a UIButton just beside UIImageView
- Put Same constraints as you put on UIImageView.
- After putting same constraints, Just delete UIImageView.
By this, it will not disturb your constraints and you will get UIButton instead of UIImageView.
You can also do as below
- Drag a UIButton just beside UIImageView
- Put Same constraints as you put on UIImageView.
- Hold down Option Key, drag Button to View (SuperView)
- Hold Down Shift to add multiple Constraints at a time.
- After putting same constraints, Simply HIDE UIImageView. Making hidden will also save your changes in code, else I might crash where you have put UIImageView references and usage in Code. You can rename UIImageView to UIButton and change throughout code also :)
Thanks
Happy Coding!
Upvotes: 1