且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

Swift macOS popover 检测更改暗模式

更新时间:2023-12-04 19:34:40

我会跳过在弹出框上设置颜色,而是在 ContentView.swift 中设置背景

Hi I would skip setting the color on the popover and instead set the background in your ContentView.swift

然后将背景设置为包装 UI 其余部分的 VStack/HStack/ZStack.

Then set the background to a VStack/HStack/ZStack wrapping the rest of the UI.

var body: some View {
        VStack{
            Text("Hello, world!").padding()
            Button("Ok", action: {}).padding()
        }
        .frame(maxWidth: .infinity, maxHeight: .infinity)
        .background(Color("backgroundTheme").opacity(0.3))
        .padding(.top, -16)
    }