作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我有一个带有 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/
我有一个带有 LongPressureGesture 的按钮,我想在这个按钮的顶部有一个小的 ProgressView,作为识别 longPressureGesture 的用户的视觉反馈。 我坚持如何
我是一名优秀的程序员,十分优秀!