Customise Uitabbar Height in Xcode11/Ios13 or 13.1

Customise UITabBar height in Xcode11 / iOS13 or 13.1

This is how I finally solve the tab bar height problem, however the position of title is still not solved, at the moment I have to use the icon image with text instead.

@IBDesignable class MyTabBar: UITabBar {

let higherTabBarInset: CGFloat = 24

lazy var isIphoneXOrHigher: Bool = {
return UIDevice().userInterfaceIdiom == .phone && UIScreen.main.nativeBounds.height >= 2436
}()

lazy var TAB_BAR_HEIGHT: CGFloat = {
// Return according to default tab bar height
if GlobalData.isIphoneXOrHigher {
return 83 + higherTabBarInset
}
else {
return 49 + higherTabBarInset
}
}()

required init?(coder aDecoder: NSCoder) {
super.init(coder: aDecoder)
if #available(iOS 13.0, *) {
self.standardAppearance.compactInlineLayoutAppearance = UITabBarItemAppearance.init(style: .stacked)
self.standardAppearance.inlineLayoutAppearance = UITabBarItemAppearance.init(style: .stacked)
self.standardAppearance.stackedLayoutAppearance = UITabBarItemAppearance.init(style: .stacked)
self.standardAppearance.stackedItemPositioning = .centered
}
}

override init(frame: CGRect) {
super.init(frame: frame)
}

override func sizeThatFits(_ size: CGSize) -> CGSize {
var size = super.sizeThatFits(size)
size.height = TAB_BAR_HEIGHT
return size
}

override func layoutSubviews() {
super.layoutSubviews()

self.items?.forEach({ e in
if #available(iOS 13.0, *) {
e.standardAppearance = self.standardAppearance
}
else {
e.titlePositionAdjustment = UIOffset(horizontal: 0, vertical: -(higherTabBarInset / 2))
}
})
}
}

Change tabBar height in Swift 5 for IOS 13

Try it in viewDidLayoutSubviews

override func viewDidLayoutSubviews() {
super.viewDidLayoutSubviews()
tabBar.frame.size.height = 95
tabBar.frame.origin.y = view.frame.height - 95
}

iPhone 10 and 11 doesn't have enough height after running the app on xcode 11

The solution is this. To those who are stuck with this problem like me.

https://github.com/tonySwiftDev/UITabbar-fixIOS12.1Bug/issues/4

Thanks!

Presenting modal in iOS 13 fullscreen

With iOS 13, as stated in the Platforms State of the Union during the WWDC 2019, Apple introduced a new default card presentation. In order to force the fullscreen you have to specify it explicitly with:

let vc = UIViewController()
vc.modalPresentationStyle = .fullScreen //or .overFullScreen for transparency
self.present(vc, animated: true, completion: nil)


Related Topics



Leave a reply



Submit