Skip to content

Instantly share code, notes, and snippets.

// Run any SwiftUI view as a Mac app.
import Cocoa
import SwiftUI
NSApplication.shared.run {
VStack {
Text("Hello, World")
.padding()
.background(Capsule().fill(Color.blue))
@markuswntr
markuswntr / SearchBar.swift
Last active November 14, 2019 19:58
SwiftUI SearchBar including a "Magnifying Glass", a "Delete Button" and a "Cancel Button"
import SwiftUI
/// Based on:
/// - https://stackoverflow.com/questions/56490963/how-to-display-a-search-bar-with-swiftui
/// - https://swiftwithmajid.com/2019/06/05/swiftui-making-real-world-app/
/// - https://gist.github.com/jstheoriginal/ebf298b33cdb4a88c3ac5f17f058aa1f
extension UIApplication {
fileprivate func endEditing(_ force: Bool) {