Monotouch UIWindow property for size without status bar?
Is there a property that is the size of the window without the size of the status bar?
I am dynamically creating a set of controls that I want to occupy the entire screen (but only the visible part), but when I base them on the main window.Frame
or window.Bounds
, the top buttons are drawn under the status bar.
I am quite new to this world, so I am probably missing so开发者_Python百科mething obvious. I could certainly do the math manually (20px, from what I read elsewhere) or I could hide it, but I was hoping there was a way to do it with something built in to the framework.
Compare UIScreen.MainScreen.Bounds with UIScreen.MainScreen.ApplicationFrame. The former "[c]ontains the bounding rectangle of the screen, measured in points." The latter contains "[t]he frame rectangle to use for your application’s window. . . . This property contains the screen bounds minus the area occupied by the status bar, if it is visible. Using this property is the recommended way to retrieve your application’s initial window size. The rectangle is specified in points." Typically, you set your UIWindow object according to UIScreen.MainScreen.Bounds so that it fills the whole screen, including the points occupied by the status bar. You set the frame of the UIView object that occupies "the entire screen (but only the visible part)" using UIScreen.MainScreen.ApplicationFrame. Then you position your buttons relative to the UIView object's geometry, and you don't have to worry about the status bar.
I do it by adjusting custom controls frames. Something like
button.Frame = new RectangleF(0, _statusBar.Frame.Bottom, button.Frame.Width, button.Frame.Height);
精彩评论