Alex Rivera | Logout

How to set a UIView's origin reference?

Asked 2012-04-04T13:45:59.610
21

I am creating a UIImageView and adding it in a loop to my view, I set the initial frame to 0,0,1,47 and each passage of the loop I change the center of the image view to space them out.

I am always using 0 as the origin.y

The problem is the origin reference is in the centre of the image view, assuming we was in interface builder, this is equivalent to the image below.

How can I change the reference point in code ?

enter image description here

Edit
Report

1 Answer

8

The object's frame includes its position in its superview. You can change it with something like:

CGRect frame = self.imageView.frame;
frame.origin.y = 0.0f;
self.imageView.frame = frame;
answered 2012-04-04T13:56:02.363

Your Answer