I have been playing around with iPhone interface building using only code and not using IB.
Now I\'m facing the following problem:
How can I set an image to
Horizontally:
UIViewAutoresizingFlexibleWidth
UIViewAutoresizingFlexibleRightMargin
UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleRightMargin
UIViewAutoresizingFlexibleLeftMargin
Vertically:
UIViewAutoresizingFlexibleHeight
UIViewAutoresizingFlexibleBottomMargin
UIViewAutoresizingFlexibleTopMargin | UIViewAutoresizingFlexibleBottomMargin
UIViewAutoresizingFlexibleTopMargin
Combine one from the first section with one from the second with a |
. For example, to have it resize horizontally and keep the same size and distance from the top vertically, you'd use UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleBottomMargin
.
You can use other combinations to do some more tricky things, but those are the basics.
You probably want this:
[myImageView setAutoresizingMask:UIViewAutoresizingFlexibleWidth];
That will keep the margins static and resize the width.