FrameView* frameView = new FrameView(); Window* window = new Window(); frameView->addSubview(window); Point framePoint(10, 10); Point windowPoint = frameView->contentsToWindow(framePoint); std::cout << "Frame Point: " << framePoint.x << ", " << framePoint.y << std::endl; std::cout << "Window Point: " << windowPoint.x << ", " << windowPoint.y << std::endl;
FrameView* frameView = new FrameView(); Window* window = new Window(); frameView->addSubview(window); Point framePoint(10, 10); Point windowPoint = frameView->contentsToWindow(framePoint); Rect windowFrame = window->getFrame(); windowFrame.origin = windowPoint; window->setFrame(windowFrame);This example is similar to the first, but also updates the position of the Window using the contentsToWindow() function. The code gets the current frame of the Window, updates the origin to the converted point, and then sets the new frame of the Window. Package Library: Cocoa Touch/UIKit