滚动到底部后如何修复iOS 15标签栏透明:
问问题
461 次
3 回答
6
在 iOS 15 中,Apple 添加了scrollEdgeAppearance
用于在边缘滚动时配置标签栏外观的属性。
要修复透明标签栏,您应该创建自定义滚动边缘外观并将其设置为标签栏。
if #available(iOS 15.0, *) {
let appearance = UITabBarAppearance()
appearance.backgroundEffect = UIBlurEffect(style: .light)
tabBar.scrollEdgeAppearance = appearance
}
于 2021-06-09T07:49:52.453 回答
6
在 iOS 15 中,UIKit 扩展了 scrollEdgeAppearance 的使用,默认情况下会产生透明背景。
由于我在我的应用程序中全局更改了标签栏颜色,因此在 iOS 15 之前,我已将以下代码添加到我的 AppDelegate:
UITabBar.appearance().barTintColor = "YOUR UITABBAR COLOR"
UITabBar.appearance().tintColor = "YOUR ICONS COLOR"
UITabBar.appearance().isTranslucent = true
为了恢复旧外观,我采用了新的 UITBar 外观 API,即 UITabBarAppearance。我将代码更改为:
UITabBar.appearance().barTintColor = "YOUR UITABBAR COLOR"
UITabBar.appearance().tintColor = "YOUR ICONS COLOR"
UITabBar.appearance().isTranslucent = true
if #available(iOS 15.0, *) {
let appearance = UITabBarAppearance()
appearance.configureWithOpaqueBackground()
appearance.backgroundColor = "YOUR UITABBAR COLOR"
UITabBar.appearance().standardAppearance = appearance
UITabBar.appearance().scrollEdgeAppearance = UITabBar.appearance().standardAppearance
}
于 2021-09-22T15:04:37.930 回答
3
init() {
if #available(iOS 15, *) {
let tabBarAppearance: UITabBarAppearance = UITabBarAppearance()
tabBarAppearance.configureWithOpaqueBackground()
UITabBar.appearance().standardAppearance = tabBarAppearance
UITabBar.appearance().scrollEdgeAppearance = tabBarAppearance
}
}
于 2021-09-20T16:03:11.643 回答