Skip to content

Instantly share code, notes, and snippets.


Stef Kors StefKors

View GitHub Profile
StefKors / DraggableView.swift
Created Jul 31, 2021 — forked from ohayon/DraggableView.swift
Example of making a reusable `draggable()` modifier for SwiftUI Views
View DraggableView.swift
struct DraggablePita: View {
var body: some View {
Image(uiImage: UIImage(named: "pita.png")!)
.draggable() // Add the new, custom modifier to make this draggable
// Handle dragging
struct DraggableView: ViewModifier {
@State var offset = CGPoint(x: 0, y: 0)