Questions tagged [draggesture]
61 questions
1
vote
1 answer
SwiftUI - Loss of .onDelete Functionality in List as a result of DragGesture
The DragGesture() causes loss of functionality of the .onDelete function inside of the list. I made a basic example of the interaction:
class MenuViewModel: ObservableObject {
@Published var dragEnabled: Bool = true
}
struct RootView: View {
…

Sam
- 13
- 4
1
vote
1 answer
TapGesture and Button is not working in list if adding simultaneousGesture with minimumDistance: 0.0 - SwiftUI
I need to use a List for reusability that it provided and disable the scroll based on adding simultaneousGesture with DragGesture(minimumDistance: 0.0) to support iOS 15. scrollDisabled is only for iOS 16.
So when adding the gesture to the list…

Sajjad Sarkoobi
- 827
- 8
- 18
1
vote
0 answers
Unable to get pixel color from an image in SwiftUI
I want to design a draggable color selector view that will select the color of the present pixel. My strategy is, first, to choose the position of the pixel and then, second, get the pixel color. The position has been correctly changed while…

Jabed Dhali
- 167
- 6
1
vote
0 answers
SwiftUI (Xcode 14.0.1) - Simultaneous Gestures (DragGesture & MagnificationGesture) - drag killed after magnification gesture activated
I am trying to achieve drag and magnification gestures take in place simultaneously. With the code below, I was able to achieve transitioning dragging to magnifying, however, when I release one finger after magnification, the drag gesture is killed…

Suguru Tokuda
- 71
- 5
1
vote
0 answers
Custom ScrollView with identical inertia and drag gesture effects as native SwiftUI ScrollView
I want to implement scrollview with snap effect + looped content and native SwiftUI ScrollView don't provide such wide customization (may be somebody will correct me), so I decided to implement my own. I'm managed to make initial drag gesture (but…

Igor Ševtšenko
- 223
- 1
- 9
1
vote
0 answers
DragGestures translation value is too big when the drag occures at the and of the frame
I have a scroll view, in which i have table. Columns of the table are resizable, and that is done through the RView, width that it is changing is the width of the column. Width of the column is set on the sample view. Total width of the table is…

Jason Krowl
- 84
- 2
- 15
1
vote
0 answers
DragGesture to scale image size in SwiftUI
Like Contacts app, once the user swap down, the thumbnail will be larger, and up for a smaller thumbnail. How to do that?
This is the sample code
@State var imageSize: CGFloat = 100.0
var maxImageSize = 300
var minImageSize = 50
var body: some…

Binh Ho
- 3,690
- 1
- 31
- 31
1
vote
1 answer
SwiftUI: How to set anchorPoint of rotateEffect in relevant to the centre of a subview/image instead of the parent view
I want to rotate a stackedImageView (which contains image and shape) based on the DragGesture's value. The rotation should rotate with the center of the stackedImageView as anchorPoint. It seems to rotate based on the centre of the parent view.
The…

user14341201
- 212
- 1
- 9
1
vote
1 answer
SwiftUI: Place and drag object immediately
I am attempting to place an object (a view of a square) on the screen and then drag it immediately. What I have achieved is the following:
I can drag existing objects that are already on the screen.
I can place new objects on the screen, but they…

Pete
- 213
- 1
- 13
1
vote
1 answer
Increase/Decrease the size of a view horizontally by dragging the edges of it
I've seen a few similar examples of this such as How to correctly do up an adjustable split view in SwiftUI? and How to resize UIView by dragging from its edges? but I can't find exactly what I'm looking for that correlates correctly across to…

Nouman
- 585
- 1
- 11
- 24
1
vote
0 answers
Drag View and Zoom In image for Portion SwiftUI
For Drag View i tried below code that only work from top-left corner.
I am Trying to drag a view from all top-left, top-right, bottom-left, bottom-right edges as it show in image, currently i can drag it from only top-left edges, i want to drag it…

Kaushik Makwana
- 142
- 1
- 14
1
vote
2 answers
How to set size limit using DragGesture() when resizing a shape in SwiftUI?
I am trying to create a resizable shape by using DragGesture() and I can't find a way to limit the size of the shape when dragging.
Here is the current output. I don't want to cross the green line.
https://i.stack.imgur.com/8XPZw.jpg
This is the…

Laur
- 71
- 1
- 9
1
vote
0 answers
fullScreenCover Dismiss with Drag SWIFTUI
Is it possible to dismiss a View with a scroll view by dragging down when in .fullScreenCover? I know .sheets can, but can it be done with fullScreenCover? I very new at swift.

Rene Robles
- 83
- 1
- 6
1
vote
1 answer
Allow DragGesture to start over a Button in SwiftUI?
The code below presents a View in the middle of the screen, and allows you to drag that View. However, if you start the drag on the Button, the drag does not work. You need to drag on the area of the View around the Button.
Is there a way to make…

Rob N
- 15,024
- 17
- 92
- 165
1
vote
0 answers
How to recreate a Pan Gesture with an animation in SwiftUI
Here is my UIPanGestureRecognizer method with an animation:
@IBOutlet weak var constraintBottomSwipe: NSLayoutConstraint!
let generator = UIImpactFeedbackGenerator(style: .heavy)
func pullViewUp(with pan:UIPanGestureRecognizer) {
let…

Luke Irvin
- 1,179
- 1
- 20
- 39