iOS獲取狀態欄和導航欄尺寸(寬度和高度)
iPhone開發當中,有時需要獲取狀態欄和導航欄高度、寬度信息,方便布局其他控件。下面介紹一下如何獲取這些信息:
// 狀態欄(statusbar)
CGRect rectStatus = [[UIApplication sharedApplication] statusBarFrame];
NSLog(@"status width - %f", rectStatus.size.width); // 寬度
NSLog(@"status height - %f", rectStatus.size.height); // 高度// 導航欄(navigationbar) CGRect rectNav = self.navigationController.navigationBar.frame; NSLog(@"nav width - %f", rectNav.size.width); // 寬度 NSLog(@"nav height - %f", rectNav.size.height); // 高度 </pre>
打印結果如下: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
本文由用戶 jopen 自行上傳分享,僅供網友學習交流。所有權歸原作者,若您的權利被侵害,請聯系管理員。
轉載本站原創文章,請注明出處,并保留原始鏈接、圖片水印。
本站是一個以用戶分享為主的開源技術平臺,歡迎各類分享!