【问题标题】:Swift Button acts like a sensor when finger passes on当手指通过时,Swift Button 就像一个传感器
【发布时间】:2018-07-02 12:47:28
【问题描述】:

我正在尝试制作这样的应用程序,但我不知道该怎么做。我已经尝试了很多东西,但它没有用,或者我无法让它工作,因为我对 swift 很陌生。 这是视频参考:https://youtu.be/6cCV_YsbUq0?t=2s

感谢您的宝贵时间

【问题讨论】:

    标签: ios swift button touch sensors


    【解决方案1】:

    我不确定,但您可以尝试触摸屏幕的 x 和 y 位置,按照此代码查找 x 和 y 位置。

    override func touchesBegan(_ touches: Set<UITouch>, with event: UIEvent?) {
        if let touch = touches.first {
            let position = touch.location(in: self.view)
            print(position.x)
            print(position.y)
        }
    }
    

    【讨论】:

      猜你喜欢
      • 2013-07-09
      • 1970-01-01
      • 2011-06-08
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多