I am new to using CGPoints to move objects around in Swift. I was wondering if you had a custom view that was of width and height 320, how you would be able to figure out the constraints of that in a CG coordinate system.
For example I have a ball object. If I set
ball.center.y = CGFloat(390) //where 390 is some random point
Then the center of y is a little above the half point line in the view. I know the top left is 0,0 for CGPoint and was wondering if there was a standard coordinate system when dealing with two dimensional coordinates.
It seems like you're looking for this Apple documentation… https://developer.apple.com/library/content/documentation/General/Conceptual/Devpedia-CocoaApp/CoordinateSystem.html
The default coordinate system has its origin at the upper left of the drawing area, and positive values extend down and to the right from it.
If you want to position the centre of your view at the centre of its superview…
let superview = view.superview!
view.center = CGPoint(x: superview.bounds.midX, y: superview.bounds.midY)