Jos*_*llo 18
在 iOS 15 中,UIKit 扩展了 \xc2\xa0scrollEdgeAppearance 的使用,默认情况下会生成透明背景。
\n\n由于我在 iOS 15 之前在应用程序中全局更改了标签栏颜色,因此我已将以下代码添加到我的 AppDelegate 中:
\nUITabBar.appearance().barTintColor = "YOUR UITABBAR COLOR"\nUITabBar.appearance().tintColor = "YOUR ICONS COLOR"\nUITabBar.appearance().isTranslucent = true\nRun Code Online (Sandbox Code Playgroud)\n为了恢复旧的外观,我采用了新的 UITBar 外观 API,UITabBarAppearance。我将代码更改为:
\n UITabBar.appearance().barTintColor = "YOUR UITABBAR COLOR"\n UITabBar.appearance().tintColor = "YOUR ICONS COLOR"\n UITabBar.appearance().isTranslucent = true\n\n if #available(iOS 15.0, *) {\n let appearance = UITabBarAppearance()\n appearance.configureWithOpaqueBackground()\n appearance.backgroundColor = "YOUR UITABBAR COLOR"\n UITabBar.appearance().standardAppearance = appearance\n UITabBar.appearance().scrollEdgeAppearance = UITabBar.appearance().standardAppearance\n }\nRun Code Online (Sandbox Code Playgroud)\n\n
Vla*_*bir 11
在 iOS 15 中,Apple 添加了scrollEdgeAppearance用于配置边缘滚动时选项卡栏外观的属性。
要修复透明选项卡栏,您应该创建自定义滚动边缘外观并将其设置到选项卡栏。
if #available(iOS 15.0, *) {
let appearance = UITabBarAppearance()
appearance.backgroundEffect = UIBlurEffect(style: .light)
tabBar.scrollEdgeAppearance = appearance
}
Run Code Online (Sandbox Code Playgroud)
init() {
if #available(iOS 15, *) {
let tabBarAppearance: UITabBarAppearance = UITabBarAppearance()
tabBarAppearance.configureWithOpaqueBackground()
UITabBar.appearance().standardAppearance = tabBarAppearance
UITabBar.appearance().scrollEdgeAppearance = tabBarAppearance
}
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
4495 次 |
| 最近记录: |