In iphone development, it is sometimes necessary to get the status bar and navigation bar height and width information to facilitate layout of other controls. Here's how to get this information:
Status bar (StatusBar) cgrect rectstatus = [[UIApplication sharedapplication] statusbarframe]; NSLog (@ "Status width-%f", rectStatus.size.width); Width NSLog (@ "Status height-%f", rectStatus.size.height); Height //navigation bar (Navigationbar) cgrect rectnav = self.navigationController.navigationBar.frame; NSLog (@ "nav width-%f", rectNav.size.width); Width NSLog (@ "nav height-%f", rectNav.size.height); Height
The printing results are as follows:
2015-01-14 13:22:22.206 app_name[226:60b] status width-320.000000 2015-01-14 13:22:22.209 app_name[226:60b] Status height-20.000000 2015-01-14 13:22:22.210 app_name[226:60b] nav width-320.000000 2015-01-14 13:22:22.211 app_name[226:60b] Nav height-44.000000
iOS get status bar and navigation bar size (width and height)