Before iOS13, I used the code below to remove the tab bar top border:
UITabBar.appearance().shadowImage = UIImage()
UITabBar.appearance().backgroundImage = UIImage()
But it does not work with iOS13, and I am looking for a solution to this. Do you have any thoughts?
Swift 4+:
In your TabBarController class write this:
if #available(iOS 13, *) {
let appearance = self.tabBar.standardAppearance.copy()
appearance.backgroundImage = UIImage()
appearance.shadowImage = UIImage()
appearance.shadowColor = .clear
self.tabBar.standardAppearance = appearance
} else {
self.tabBar.shadowImage = UIImage()
self.tabBar.backgroundImage = UIImage()
}
For title adjustment use this:
appearance.stackedLayoutAppearance.normal.titlePositionAdjustment = UIOffset(horizontal: 0, vertical: -12)
For Objective C
if (@available(iOS 13.0, *)) {
UITabBarAppearance* appearance = self.tabBar.standardAppearance.copy;
appearance.backgroundImage = [UIImage new];
appearance.shadowImage = [UIImage new];
appearance.shadowColor = [UIColor clearColor];
// Title adjustment
appearance.stackedLayoutAppearance.normal.titlePositionAdjustment = UIOffsetMake(0, -12);
self.tabBar.standardAppearance = appearance;
} else {
self.tabBar.shadowImage = [UIImage new];
self.tabBar.backgroundImage = [UIImage new];
}