Skip to content

Instantly share code, notes, and snippets.

View brunogb's full-sized avatar

Bruno Bilescky brunogb

  • Hudl
  • London, UK
View GitHub Profile
@brunogb
brunogb / SwiftUIDragDrop.swift
Last active July 1, 2020 17:44
Drag'n'Drop with SwiftUI
import SwiftUI
import PlaygroundSupport
struct MyView: View {
@State var viewOffset: CGSize = .zero {
didSet {
let newFrame = viewFrame.offsetBy(dx: self.viewOffset.width, dy: self.viewOffset.height)
self.canDrop = containerFrame.intersects(newFrame)
import SwiftUI
import PlaygroundSupport
struct Desktop: View {
var body: some View {
ZStack {
// Image(uiImage: #imageLiteral(resourceName: "IMG_6281.JPG"))
Color(UIColor.systemBlue)
macOS()
}