10 override func touchesBegan(_ touches:Set<UITouch>,
with event:UIEvent?) {
11 let touch = touches.first
12 let touchPoint = touch?.location(in:self.view)
13
14 let imageViewFrame = self.imageView.frame
15 let minX = imageViewFrame.origin.x
16 let minY = imageViewFrame.origin.y
17 let maxX = minX + imageViewFrame.size.width
18 let maxY = minY + imageViewFrame.size.height
19 if (touchPoint?.x)!>= minX && (touchPoint?.y)!
<= maxX && (touchPoint?.y)!>= minY &&(touchPoint?.y)!<= maxY
20 {
21 isTouchInImageView = true;
22 print(“您捡到一枚星星”);
23 }
24 }
image.png