目标是在Mac Catalyst上制作一个半透明的侧边栏。
下面的代码提供了一个非半透明的侧边栏(图1)。
在Mac上(不是catalyst),侧边栏看起来很好(图2)。
在Mac Catalyst上是否可能拥有一个半透明的侧边栏?
import SwiftUI
struct ContentView: View {
var body: some View {
NavigationView {
//sidebar
List {
Label("Books", systemImage: "book.closed")
Label("Tutorials", systemImage: "list.bullet.rectangle")
}
.background(Color.clear)
.listStyle(SidebarListStyle())
//content
Text("Sidebar")
.navigationTitle("Sidebar")
}
}
}