Skip to content

Instantly share code, notes, and snippets.

@MojtabaHs
Last active January 11, 2020 06:42
Show Gist options
  • Save MojtabaHs/f589f29c100f95d6b6c1bb11367857b1 to your computer and use it in GitHub Desktop.
Save MojtabaHs/f589f29c100f95d6b6c1bb11367857b1 to your computer and use it in GitHub Desktop.
This is a simple file you can use to bring any AppKit NSView in to the SwiftUI. Fully customizable.
struct <#NSViewForSwiftUI#>: NSViewRepresentable {
typealias TheNSView = <#The Original UIView Type#> /* e.g. NSProgressIndicator */
var configuration = { (view: TheNSView) in }
func makeNSView(context: NSViewRepresentableContext<ProgressIndicator>) -> NSProgressIndicator {
TheNSView()
}
func updateNSView(_ nsView: NSProgressIndicator, context: NSViewRepresentableContext<ProgressIndicator>) {
configuration(nsView)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment