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
Swift Core Data Sync with Web Server
Masked Uivisualeffectview Does Not Work on iOS 10
Validate Jwt Token with Rs256 or Rs512 with Swift iOS
Wkwebview Blank After 'Successful' Https Nsurlrequest
Swiftui Tabbedview Only Shows First Tab's Content
How to Call Presentviewcontroller in Uiview Class
Xcode 6 Project Crashing After Segue on iOS 7.1
Setup a Collectionview with "Tag"-Like Cells
Timer Label Not Updated After Switching Views (Swift)
Returning Data from Function in Firebase Observer Code Block Swift
Periodically Call an API with Rxswift
Unusernotificationcenter.Current().Getdeliverednotifications Only Ever Returns an Empty Array
Gmsmarker Icon in the Top Left Corner of the View (Ios)
How Is It I Can Animate the Change in Bar Tint Color of a Uinavigationbar But Not a Uitabbar
How Do View Types Like Text or Image Conform to the View Protocol in Swiftui