简体   繁体   中英

How to Handle Duration Time Long Pressed SwiftUI

.gesture(LongPressGesture(minimumDuration: 0, maximumDistance: 10.0).onChanged(){})

Hi here is example for change duration of gesture according to your need:


      Rectangle()
            .fill(isPressing ? Color.orange : .gray)
            .frame(width: 50, height: 30)
            .onLongPressGesture(minimumDuration: 0.25, maximumDistance: 50, pressing: { (isPressing) in
            if isPressing {
                // called on touch down
            } else {
                // called on touch up
                message = "TAP"
            }
        }, perform: {
            message = "LONG\nPRESS"
        })

 

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM