Search code examples
objective-cmacosautoresizingmaskautolayout

How to layout these views in OS X?


Consider 3 views header, body and footer with the following restrictions:

  • header must be shown on top and has fixed height
  • footer must be shown at the bottom and has fixed height
  • body must fill the space between header and footer

Is it possible to layout these views with autoresizing masks? How?

If not, is it possible to layout these views with auto layouts? How?


Solution

  • If it works the same as in UIKit :

    • header and footer have all 4 fixed margins, fixed height, but flexible width : UIViewAutoresizingFlexibleWidth. In IB, the 4 margins are switched on (lit), the horizontal arrow (width) is on (lit), but the vertical arrow (height) is off (unlit).
    • body has all 4 fixed margins, but flexible width and height : UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight. In IB, the 4 margins are switched on (lit), and both arrows are on too.