user640250
user640250

Reputation: 31

How do you change the coordinates of a UIImageView?

I have made a UIImageView show an image of my choosing in Interface Builder.

In code, I want to find a way to change the x and y coordinates of this image view, during the program.

Is it possible to do that?

I've already made a variable

IBOutlet UIImageView *Alan;

but am not sure what to do with it.

Upvotes: 0

Views: 4698

Answers (1)

Vladimir
Vladimir

Reputation: 170859

Change view's frame property:

Alan.frame = (CGRect){{newX, newY}, Alan.frame.size};
// same as 
// Alan.frame = CGRectMake(newX, newY, Alan.frame.size.width, Alan.frame.size.height);

or if you want to set position of view center:

Alan.center = CGPointMake(newX, newY);

P.S. Note also that per objective-c naming guidelines instance variable names should start with lowercase.

Upvotes: 4

Related Questions