Group views in Interface Builder

前端 未结 2 1868
孤街浪徒
孤街浪徒 2021-02-05 11:46

Is there any way to move a group of views within another without grouping all in the center?

Edit: Here some images with the process.

1.- I have

2条回答
  •  再見小時候
    2021-02-05 12:15

    I found a very nifty solution that you are not gonna believe .. !

    I had a group of like 30 labels and buttons positioned pixel by pixel, so I HAD to, no matter what, move them while preserving their relative locations to each other.. Here is what I did:

    1. Select all the views (labels, button, ... etc)
    2. Editor -> Embed In -> View. (Now, they are in a view)
    3. Move that view wherever you like. (Heck, you can even cut and paste it to a new NIB!)
    4. Selected the view, Editor -> Unembed ! :D

    I haven't read this anywhere, I came up with it yesterday .. Am 100% sure people somewhere have found this way before me, though.

    EDIT:

    It seems Xcode 4.5 renders this answer obsolete. Copy/Pasting a bunch of views now retains their relative locations to each other. Don't bother with this if you grew a habit on using it!

    Actually, I think this answer is still viable!

提交回复
热议问题