开发者

UIView as container in IB?

开发者 https://www.devze.com 2023-04-12 13:37 出处:网络
Is there a way to place components like labels and buttons inside a container like a UIView in IB solely for the purpose of moving those components aro开发者_运维问答und as a whole? I don\'t need the

Is there a way to place components like labels and buttons inside a container like a UIView in IB solely for the purpose of moving those components aro开发者_运维问答und as a whole? I don't need the container to have any functionality, just serve as an easy way to drag around a group of IB components inside IB. I tried putting components inside a UIView but the UIView is not easily selectable to drag around.

Thanks!


Yes, there is, you just have to make sure you use the hierarchical structure of elements/objects in your IB

What I mean is make sure that each of the objects you want in your container view are CHILDREN of the container view (visible as indented beneath) in the Navigator Pane. (Make sure your left navigator window is showing -- see segmented control top right of xcode -- by clicking the left most item).

Within the navigator you will see all of your objects listed Drag the objects you want in your container until you make them indent below the container (UIVIEW) this is sometimes kind of tricky I find. Once all of the children are in the container view select the container by clicking on it in the navigator and then in the view pane (in the middle) drag the container UIView where you want it.

This is very helpful for grouping things together as well as hiding, revealing, moving or animating a group of objects programatically. (FWIW, I find the best way to hide/reveal the view is to make the container UIView have a height or width of 0. Then reset to normal width when you want it visible. I've had trouble marking it hidden). Make sure the background of your objects and UIView are clear (if appropriate).

Good luck hope this helps.

0

精彩评论

暂无评论...
验证码 换一张
取 消