Post

Replies

Boosts

Views

Activity

Reply to LazyVGrid is offset when using NSApplicationDelegateAdaptor
Alrighty, I think I've got a temp fix. I think the problem is that when initiated a view somewhere in the hierarchy of SwiftUI with LazyVGrid doesn't recognize those AppKit elements but then does once refreshed. So to refresh, flipping the view helps, but it has to be done 2 times to get it back to normal 😆. Not sure if the have to be positioned on a specific view but add the following extension. extension View {     public func flip() -> some View {         return self             .rotationEffect(.radians(.pi))             .scaleEffect(x: -1, y: 1, anchor: .center)     } } Here is my view implementation         VStack(alignment: .trailing, spacing: 0) {         ScrollView {             ScrollViewReader { reader in                 ZStack {                     Rectangle().foregroundColor(.blue)                     ListView()                 }             }         }.flip()         .flip()         } And cross your fingers it works.
Jun ’20
Reply to How to open a window in SwiftUI?
To my knowledge AppDelegate is the only way for now, place it in you App file as a var like so     @NSApplicationDelegateAdaptor(AppDelegate.self) var appDelegate     var body: some Scene {         Settings {         } } Then have your window class class AppWindow: NSWindow {     init() {         super.init(contentRect: NSRect(x: 0, y: 0, width: 480, height: 300), styleMask: [.titled, .closable, .miniaturizable, .resizable, .fullSizeContentView], backing: .buffered, defer: false)         makeKeyAndOrderFront(nil)         isReleasedWhenClosed = false         styleMask.insert(NSWindow.StyleMask.fullSizeContentView)         title = "title placeholder"         contentView = NSHostingView(rootView: ContentView())     } }
Jun ’20