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?
- Blinking effect on UILabel
- Is it possible to set UIView border properties from interface builder?
- how to draw CALayer with line path like simulate eraser effect?
- On iOS, is there a way to search ONLY subviews with a certain tag?
- Detecting collisions between rotated UIViews
- iOS subview displayed as a black rectangle if drawRect is overwritten
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];
- How to find the text in an NSTextView?
- Swift – how to use malloc?
- numberOfRowsInSection is called before Alamofire connection
- How to convert NSUrl to NSString?
- iOS segue executed twice
- Programmatically open Maps app in iOS 6
- Auto Layout with navigation bar and view controller (iOS 7)
- Xcode reference a framework instead of link binary with libraries
- iOS 7 UIImagePicker preview black screen
- camera overlay picture
- How do I get the current Date in short format in Swift
- How to limit the tap of a ball in Swift 3/SpriteKit?
- RealmSwift RLMException
- Ambiguous type name error
- How do you enable touch selection of a section in a Core Plot pie chart?