Let’s say I need to create a tab bar with 3 tabs, each having a button and an indicator. It needs to be responsive (autoresizeable) and each tab equally sized with the others.
Using Auto Layout here is how I do it.
1. Select a view that renders a tab (here called “TabView”). Copy-paste as many as needed. Customize each copy.
2. Add missing constraints manually. Select each tab view, uncheck “Constrain to margins”, and add space constraints. The first tab needs 4 constraints, the rest - only 3.
3. Add size constraints (width or height) by selecting all tab views, then Equal Widths.
4. Finally, update all frames in a parent view.
Embed in a parent controller, declare protocols to handle taps, etc.
No comments:
Post a Comment