Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SwiftUI - Catalyst translucent sidebar

Goal is to make a translucent sidebar on Mac Catalyst.

The code bellow gives a not translucent sidebar (image 1).

On Mac (not catalyst) the sidebar looks fine (image 2).

is it possible to have a translucent sidebar on Mac Catalyst?

enter image description here

enter image description here

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")
        }
        
        
    }
}
like image 776
Mane Manero Avatar asked Jan 11 '21 19:01

Mane Manero


1 Answers

Start with the AppDelegate main and follow Apple's tutorial re: UISplitViewController "Apply a Translucent Background to Your Primary View Controller".

https://developer.apple.com/documentation/uikit/mac_catalyst/optimizing_your_ipad_app_for_mac

In wrapping UISplitViewController in a UIViewControllerRepresentable, I wasn't able to get translucency, but did get full-height sidebar.

like image 198
Ryan Avatar answered Sep 16 '22 13:09

Ryan