如果 TouchLocation 不在边界内
If TouchLocation is NOT Within Bounds
对于下面的代码,我需要查看 touchLoaction 是否不在按钮的范围内,但我遇到的问题是不能使用 !=,所以我不能 100% 确定是什么我需要输入。每次我在网上搜索 "if not equal" 时,它只会显示“!=”示例,在这种情况下不起作用。
let touch = touches.first as UITouch!
let touchLocation = touch.locationInNode(self)
if button.containsPoint(touchLocation) { // NEEDS TO BE NOT CONTAINSPOINT OR SOMETHING
print("not on button")
}
这应该有效:if (button.containsPoint(touchLocation) == False)
Declaration
Swift: func containsPoint(_ point: CGPoint) -> Bool
Objective-C: - (BOOL)containsPoint:(CGPoint)point
在两种语言中 containsPoint
returns 一个 BOOL(可以等于 false。)
对于下面的代码,我需要查看 touchLoaction 是否不在按钮的范围内,但我遇到的问题是不能使用 !=,所以我不能 100% 确定是什么我需要输入。每次我在网上搜索 "if not equal" 时,它只会显示“!=”示例,在这种情况下不起作用。
let touch = touches.first as UITouch!
let touchLocation = touch.locationInNode(self)
if button.containsPoint(touchLocation) { // NEEDS TO BE NOT CONTAINSPOINT OR SOMETHING
print("not on button")
}
这应该有效:if (button.containsPoint(touchLocation) == False)
Declaration
Swift:
func containsPoint(_ point: CGPoint) -> Bool
Objective-C:
- (BOOL)containsPoint:(CGPoint)point
在两种语言中 containsPoint
returns 一个 BOOL(可以等于 false。)