Position a UIView relative to the bottom of the pa

2019-01-17 17:21发布

How can I align a UIView to the bottom of the parent so that the Y coordinate of the frame is relative to the bottom of the screen instead of the top?

This would be the equivalent to setting the .bottom property in HTML.

This is because I want to make sure my view is always at the bottom of window regardless of the height of the parent.

3条回答
兄弟一词,经得起流年.
2楼-- · 2019-01-17 17:35

This should do the trick

public override void ViewDidLoad()
{
    base.ViewDidLoad();
    bottomButton.Alignment = UIStackViewAlignment.Bottom;          
}
查看更多
对你真心纯属浪费
3楼-- · 2019-01-17 17:43

You can set the autoresizing mask values on the Sizing pane in XIB or Storyboard editor.

查看更多
老娘就宠你
4楼-- · 2019-01-17 17:53

Once you have initially positioned the view by setting its frame property, adjust its autoresizingMask to include UIViewAutoresizingFlexibleTopMargin. That will keep it anchored to the bottom of its superview.

查看更多
登录 后发表回答