Reputation: 1888
Trying to find applications current position in X Y coordinate. For example: An application has starting point(X,Y) + Hight, Width. How to find its starting point as CGPoint or X Y onscreen values?
Current trying with view.bounds
:
class ViewController: NSViewController {
var testPoint = CGPoint.zero;
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view.
//testPoint = view.bounds.height //rect
//if possible following:
//testPoint = CGPoint(x: view.window?.frame.origin.x , y: view.window?.frame.origin.y)
print(testPoint)
}
}
Upvotes: 1
Views: 467
Reputation: 285260
In viewWillAppear
or viewDidAppear
ask the window
of the view
for the origin
of its frame
override func viewWillAppear() {
super.viewWillAppear()
print(view.window?.frame.origin)
}
Upvotes: 2