Split the CGPoint numbers in two CGFloat

516 views Asked by At

Hey guys I have a UIImage that should move to a position which the CGPoint tells.

My code:

person1 = UIImageView(frame: CGRectMake(corX, corY, 25, 25))

What I want to do is to split the CGPoint in two numbers which initialise corX and corY. Hopefully you can help me.

-Lukas

1

There are 1 answers

2
Martin R On BEST ANSWER

CGPoint has properties x and y:

person1 = UIImageView(frame: CGRectMake(point.x, point.y, 25, 25))

Alternatively create the CGRect directly from your point as the origin and a given size:

person1 = UIImageView(frame: CGRect(origin: point, size: CGSize(width: 25, height: 25)))