Change Position and Image of UIImageView

Hi,
I got following code to change my ImageView

[UiImageView setContentMode:UIViewContentModeRedraw];
[UiImageView setBounds:CGRectMake( 0, 0, 50, 50)];

I now hot to change it with last two numbers, but there is no difference if first two numbers change.
How can I change the position of it like

UiImageView.left = 100
UiImageView.top = 50
(Thats what it looks like in .net)

And my second problem is:

How can I switch different pictures in my UiImageView???

Thanks to all

Mac Mini, Mac OS X (10.5.4)

Posted on Oct 16, 2008 10:21 AM

Reply
2 replies

Oct 16, 2008 11:58 AM in response to Haekki

To change the position of a UIView (or subclass):

CGRect frame = myView.frame;
frame.origin.x = 12.0;
frame.origin.y = 3.0;
// optionally change the size as well
// frame.size.width = 100.0;
// frame.size.height = 250.0;
myView.frame = frame;


OR


myView.frame = CGRectMake(12.0, 3.0, 100.0, 250.0);


Unfortunately you CANNOT do something like this:

myView.frame.size.x = 100.0;

because ".frame" is not really accessing the variable directly; it is sending a message (calling a method) behind the scenes. Read about properties in the Objective-C 2.0 reference. However ".size.x" is a normal C struct access.

This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

Change Position and Image of UIImageView

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.