【问题标题】:Swift: Haptic effects for grid of UIButtonsSwift:UIButtons 网格的触觉效果
【发布时间】:2020-08-24 19:06:32
【问题描述】:

我有一个 UIButton 网格,我想为以下方法调用触觉效果:

  1. 当用户第一次将手指移到按钮上时
  2. 当用户抬起手指时(典型的点击,.touchUpInside 可以完美运行)

关于当用户第一次移过按钮时如何调用触觉效果有什么建议吗?

    button.addTarget(self, action: #selector(tap), for: .touchUpInside)
    button.addTarget(self, action: #selector(moveOver), for: .??)

func moveOver(sender:UIButton) -> Bool {
        let generator = UIImpactFeedbackGenerator(style: .heavy)
        generator.impactOccurred()
        return true
}

【问题讨论】:

    标签: uibutton uievent


    【解决方案1】:

    在这种情况下使用的正确 UIEventAction 是 touchDragInside

    【讨论】:

      猜你喜欢
      • 2012-08-22
      • 1970-01-01
      • 2020-05-23
      • 1970-01-01
      • 2016-09-03
      • 1970-01-01
      • 1970-01-01
      • 2021-05-20
      • 1970-01-01
      相关资源
      最近更新 更多