CGPoint relative to view
Consider a screen point (CGPoint) and a view (UIView), which is somewhere inside the view hierarchy (it can be a subview of other views).
How can you convert the point to a point relative to the view’s coordinates?
Solutions Collect From Internet About “CGPoint relative to view”
First, convert the point from screen coordinates to the coordinates of your main window:
UIWindow *mainWindow = [[UIApplication sharedApplication] keyWindow]; CGPoint pointInWindowCoords = [mainWindow convertPoint:pointInScreenCoords fromWindow:nil];
Second, convert the point from window coords to view coords:
CGPoint pointInViewCoords = [myView convertPoint:pointInWindowCoords fromView:mainWindow];
- AVAudioPlayer – playing multiple audio files, in sequence
- IOS StoryBoard multiple Segue's from a TableCell
- iOS ADMOB Reward based video ad failed to load
- UIWebView set initial zoom scale programmatically when loading an external website?
- Creating a Cocoa application without NIB files
- iOS SDK: How to invoke E-mail application?
- Adding relationships in NSManagedObjectModel to programmatically created NSEntityDescription
- Roboto font for ios
- What is a StoryBoard ID and how can i use this?
- How to quit itself in Objective-C application?
- CCMenu misplaced under iOS 7
- Undefined symbols for architecture armv7: “_SCNetworkReachabilityCreateWithAddress”
- Xcode 5/6: View Debugging always grayed out?
- Checking for nil Value in Swift Dictionary Extension
- Compare two arrays with the same value but with a different order