views:

685

answers:

1

How can I align my UIView so that it aligns to the bottom of parents frame?

Normally I would create it and move to the bottom of the view, in a full screen view that is 460px tall:

myView = [[MYView alloc] initWithFrame::CGRectMake(0.0f, 300.0f, 320.0f, 160.0f)];

But how can I set this up so that if the available space for my iPhone app's screen is 440px (e.g. iPhone tethering is turned on or another value if it's running on the mythical iTablet). I'm guessing that I will have set the 'centre' to the bottom of MYViews frame, but I can't figure out what else. Any help appreciated...

+1  A: 

if you create the view within a view controller, you could do this;

myView = [[MYView alloc] initWithFrame:CGRectMake(0, self.view.frame.size.height - 160.0f, 320.0f, 160.0f)];

It takes the height of its parent (minus the height of the view itself) for the y-axis.

MiRAGe
I had to use self.view i.e. and it worked... self.view.frame.size.heightthanks
Ross
Christopher Stott
It doesn't. And with Apple's new way of thinking (points, not pixels!) this answer is no longer valid.
MiRAGe