gpt4 book ai didi

ios - 无法在 iOS 13 中设置标签栏阴影图像

转载 作者:搜寻专家 更新时间:2023-11-01 06:10:47 26 4
gpt4 key购买 nike

在iOS13之前,我使用下面的代码去除标签栏的上边框:

UITabBar.appearance().shadowImage = UIImage()
UITabBar.appearance().backgroundImage = UIImage()

但它不适用于 iOS13,我正在寻找解决方案。你有什么想法吗?

最佳答案

swift 4+:

在你的 TabBarController 类中这样写:

 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()
}

对于标题调整使用这个:

appearance.stackedLayoutAppearance.normal.titlePositionAdjustment = UIOffset(horizontal: 0, vertical: -12)

针对 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];
}

关于ios - 无法在 iOS 13 中设置标签栏阴影图像,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58062613/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com