【轉】iPhone獲取狀態欄和導航欄尺寸(寬度和高度)


原文網址:http://blog.csdn.net/chadeltu/article/details/42708605

iPhone開發當中,有時需要獲取狀態欄和導航欄高度、寬度信息,方便布局其他控件。下面介紹一下如何獲取這些信息:

 

[objc]  view plain  copy
 
  1. // 狀態欄(statusbar)  
  2. CGRect rectStatus = [[UIApplication sharedApplication] statusBarFrame];  
  3. NSLog(@"status width - %f", rectStatus.size.width); // 寬度  
  4. NSLog(@"status height - %f", rectStatus.size.height);   // 高度  
  5.   
  6. // 導航欄(navigationbar)  
  7. CGRect rectNav = self.navigationController.navigationBar.frame;  
  8. NSLog(@"nav width - %f", rectNav.size.width); // 寬度  
  9. NSLog(@"nav height - %f", rectNav.size.height);   // 高度  


打印結果如下:

 

 

[plain]  view plain  copy
 
    1. 2015-01-14 13:22:22.206 app_name[226:60b] status width - 320.000000  
    2. 2015-01-14 13:22:22.209 app_name[226:60b] status height - 20.000000  
    3. 2015-01-14 13:22:22.210 app_name[226:60b] nav width - 320.000000  
    4. 2015-01-14 13:22:22.211 app_name[226:60b] nav height - 44.000000  


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM