I have a UIImageView
and I have a CGPoint
on the screen. I want to be able to test that point to see if it is in the UIImageView
. What would be the best way to do this?
相关问题
- CALayer - backgroundColor flipped?
- Core Data lightweight migration crashes after App
- How can I implement password recovery in an iPhone
- how do you prevent page scroll in textarea on mobi
- Custom UITableview cell accessibility not working
相关文章
- Could I create “Call” button in HTML 5 IPhone appl
- xcode 4 garbage collection removed?
- Xcode: Is there a way to change line spacing (UI L
- Unable to process app at this time due to a genera
- Popover segue to static cell UITableView causes co
- How do you detect key up / key down events from a
- “Storyboard.storyboard” could not be opened
- didBeginContact:(SKPhysicsContact *)contact not in
CGPoint
is no good with a reference point. If your point is in window's coordinates then you can get it usingYou may also call
pointInside:withEvent:
methodwhere point is your CGPoint and myView is your UIImageView
Tested in Swift 4
In Swift 3
I'll assume you have a full-screen window (pretty reasonable, I think). Then you can transform the point from the window's coordinate space to the UIImageView's using:
Then, you can test if the point is in the image view's frame as follows: