See that 20px (pt's rather) of padding? IB does it automatically in two cases, when you hit Cmd + =
to autosize the superview to fit subview contents, and when you choose Editor > Embed In > UIView, UIScrollView etc.
.
The later is especially annoying as it takes what should be a one step time saver and turns it into a repositioning hassle that is only marginally better than doing it manually and losing the relative positioning of ALL the subviews when you drag them into a different place in the hierarchy.
Also with the Embed In
option, IB shifts the positioning of the new superview wrapper by (-20, -20) as if that makes it better...
Am I missing something here? Is there a way to prevent this padding?
I finally figured out how to do it, related to this answer:
Group views in Interface Builder
Now your child elements are correctly positioned within view "B", and there is no 20 pixel padding.
Tested in Xcode 4.5.
P.S. this technique can be especially useful when you wish to have a sidebar and support both 3.5" and 4" displays. You can give the sidebar and main view the appropriate autosizing and then scale subviews in relation to them. I was having trouble getting GLKit views to respect autosizing rules, so I set up ordinary views and embedded the GLKKit views within them with all of the red autosizing bars enabled:
GLKView nested subview frame size and bounds size incorrect
What a great news ! This is finally possible to embed views in UIView
without any tweaking thanks to Xcode 10 !
Just use the new View Without Insets
submenu.
As of now, they didn't do the same for UIScrollView
yet…
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With