简体   繁体   English

滚动时不透明的背景工具栏

[英]Opaque background Toolbar when scrolling

I have opaque the background of the TabBar but not the ToolBar when I expected both...当我期望两者时,我有不透明的 TabBar 背景而不是 ToolBar ......

.onAppear{
    let tabBarAppearance = UITabBarAppearance()
    tabBarAppearance.configureWithOpaqueBackground()
    UITabBar.appearance().standardAppearance = tabBarAppearance
    let toolBarApperance = UIToolbarAppearance()
    toolBarApperance.configureWithOpaqueBackground()
    UIToolbar.appearance().standardAppearance = toolBarApperance
    UIToolbar.appearance().scrollEdgeAppearance = toolBarApperance
  } 

Some hint plis;)一些提示 pli;)

toolbarBackground(_:for:) solves the problem but only in iOS 16 toolbarBackground(_:for:)解决了问题,但仅在 iOS 16

if #available(iOS 16.0, *) {
  ...
  .toolbarBackground(Color.black, for: .automatic)
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM