user2636197
user2636197

Reputation: 4122

Swift change cgpoint .center value

I am using a CGPoint value to set where a animation starts.

transition.startingPoint = startButton.center

If I do print(startButton.center) the output will be: (292.0, 22.0)

What I now want to do is to edit that values Y position so the animation starts a bit lower on the screen and I can pass the new value to the transition.startingPoint = newVal

Upvotes: 1

Views: 3388

Answers (1)

alexburtnik
alexburtnik

Reputation: 7741

Here is what you need:

var startingPoint = startButton.center
startingPoint.y += 20
transition.startingPoint = startingPoint

Or:

let buttonCenter = startButton.center
transition.startingPoint = CGPoint(x: buttonCenter.x, y: buttonCenter.y + 20)

Upvotes: 6

Related Questions