How do I get the current x and y position so that I can use GCRectMake?
Asked Answered
C

1

34

I have this code inside an animation:

image.frame = CGRectMake(x: x, y: y, width, height)

I need to get the x and y coordinates of an image. I found this Objective-C code:

CGPoint origin = imageView.frame.origin;

Once I find the x and y position of the image, I will need to transform it. I will use something like:

image.frame = CGRectMake(x-50, y-50, width+500, height+500)

...so that I can move the image around the screen. How do I find the original x and y positions?

Certainly answered 18/1, 2015 at 10:41 Comment(0)
E
77

Do you mean you want this?

var frm: CGRect = imageView.frame
frm.origin.x = frm.origin.x - 50
frm.origin.y = frm.origin.y - 50
frm.size.width = frm.size.width + 500
frm.size.height = frm.size.height + 500
imageView.frame = frm
Ellaelladine answered 18/1, 2015 at 10:52 Comment(3)
Is there any way to get the width and the height original values? ThanksCertainly
frm.size.width and frm.size.height are original valuesEllaelladine
what is frame.origin.y, is it midY, maxY, or minY?Sapor

© 2022 - 2024 — McMap. All rights reserved.