I am trying to use a Swift function to place a circle in the centre of a view so it is always on centre regardless of screen size. I can draw the circle at a point defined by a
Your screenCenter
function returns a tuple containing two CGFloat
values. These values are labeled x
and y
so you can access them by name when querying the function’s return value.
override func viewDidLoad() {
super.viewDidLoad()
let center = screenCentre()
//center.x contains the x value returned from screenCenter
//center.y contains the y value returned from screenCenter
circle(x: center.x , y: center.y)
}