Running the app in iPad with iPadOS 18.1, it shows the TabView in a different layout and position.
I want to keep the Bottom TabView using full width with icons.
Does Apple is removing the old style and forcing us to implement a custom TabView, or use a new one?
I already tried the Styles on Apple’s documentation, but none of them fixes it.
https://developer.apple.com/documentation/swiftui/tabviewstyle
2
Answers
Correct. See the Human Interface Guidelines on the platform considerations of tab bars.
The release notes of iOS 18 also mentions this:
Since this says "in the regular horizontal size class", it is possible to get the old style back by setting the environment value to
.compact
.But I’d imagine this would cause problems later down the line. It’s better to follow the HIG.
In iOS and iPadOS, size classes (compact and regular) control the layout behaviour of UI elements.
We can get the old behaviour using TraitOverrides. This solves the issue.
Swift:
self.traitOverrides.horizontalSizeClass = UIUserInterfaceSizeClass.compact