开发者

Align UIView to bottom of parent's frame / view

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 开发者_JS百科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...


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜