gpt4 book ai didi

ios - 按钮上 LongPressureGesture 的进度

转载 作者:行者123 更新时间:2023-11-28 13:00:54 25 4
gpt4 key购买 nike

我有一个带有 LongPressureGesture 的按钮,我想在这个按钮的顶部有一个小的 ProgressView,作为识别 longPressureGesture 的用户的视觉反馈。

我坚持如何检测 longPressure 的开始和 longPressure 的持续时间以便能够在我的 ProgressView 上设置 setProgress()

编辑:所以我从答案中得到启发,谢谢。这是我做的。欢迎评论以下代码,也许有更好的解决方案。

private var lpProgress:Float = 0
private var startTouch: NSTimer!

@IBAction func pauseJogButtonTouchDown(sender: AnyObject) {
self.startTouch = NSTimer.scheduledTimerWithTimeInterval(0.1, target: self, selector: "updateLPGestureProgressView", userInfo: nil, repeats: true)
}

func updateLPGestureProgressView() {
self.lpProgress += 0.1
self.lpGestureProgressView.setProgress(self.lpProgress, animated: true)
if self.lpProgress >= 1 {
self.startTouch.invalidate()
self.pauseBarButton.hidden = true
self.lpGestureProgressView.setProgress(0.0, animated: false)
self.toolbarHomeMadeView.hidden = false
self.switchToState(.Paused)
}
}

@IBAction func pauseJogButtonTouchUpInside(sender: AnyObject) {
self.lpProgress = 0
self.startTouch.invalidate()
self.lpGestureProgressView.setProgress(0.0, animated: false)
}

最佳答案

在这种情况下,您不需要 LongPressureGesture。使用 UIButton 的“Touch Down”IBAction 启动 NSTimer,使用“Touch Up Inside”停止计时器并检查延迟是否正确。ProgressView 您可以按计时器进度填充。

关于ios - 按钮上 LongPressureGesture 的进度,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33898978/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com