-
-
Save calt/7ea29a65b440c2aa8a1a to your computer and use it in GitHub Desktop.
// Does not work on iOS 14.0 or later, keeping the gist just for reference. | |
extension UITabBar { | |
override open func sizeThatFits(size: CGSize) -> CGSize { | |
super.sizeThatFits(size) | |
var sizeThatFits = super.sizeThatFits(size) | |
sizeThatFits.height = 71 | |
return sizeThatFits | |
} | |
} |
@RemiRodrigues Thanks, you really saved me a lot of headaches.
@Wei18 Thank you man it works like a charm!
@Wei18 you are a champ
@Wei18 Thank you that's work for me too on iOS 14+
@Wei18 thank you! still working for swift 5+
New to Swift over here! - Trying to understand how I would use this in Views. Here is my Tabs View `struct Tabs: View {
@EnvironmentObject private var themeManager: ThemeManager
@Environment(.colorScheme) var mode: ColorScheme
@State private var selectedTab = 0
var body: some View {
TabView(selection: $selectedTab) {
DetailsView()
.tabItem {
Text("Home")
TabImage(name: "misty", size: CGSize(width: 42, height: 42))
}
.tag(0)
SettingsView()
.tabItem {
Text("Socials")
TabImage(name: "laptop", size: CGSize(width: 42, height: 42))
}
.tag(1)
}
.onAppear(perform: {
CustomTabBar().sizeThatFits(CGSize(width: 300, height: 400))
})
.accentColor(AppColors(mode: mode).jnjBorder)
}
}`
With the extension class CustomTabBar : UITabBar { override open func sizeThatFits(_ size: CGSize) -> CGSize { super.sizeThatFits(size) var sizeThatFits = super.sizeThatFits(size) sizeThatFits.height = 71 return sizeThatFits } }
However my emulator is still showing all clumped up. I've tried a few other ways to try and increase the height but nothing seems to work!
Work for me in iOS 14+, and others