我们可以使用以下方式在ios应用中禁用和启用用户互动

UIApplication.shared.beginIgnoringInteractionEvents()
UIApplication.shared.endIgnoringInteractionEvents()


如何禁用MAC App用户交互?我们可以禁用视图互动,但不能禁用整个应用。有什么解决办法吗?

最佳答案

您可以使用hitTest禁用它。

class CAInteractionView: NSView {

var isUSerIntactionEnable:Bool = true
override func hitTest(_ point: NSPoint) -> NSView? {
    if(self.isUSerIntactionEnable) {
        return super.hitTest(point)
    }
    return nil
}
override func draw(_ dirtyRect: NSRect) {
    super.draw(dirtyRect)

    // Drawing code here.
}


}

像这样称呼它

  if let cView =  self.view as? CAInteractionView {
     cView.isUSerIntactionEnable = false
  }

09-10 00:40
查看更多