iOS Statusbar

日本語はこちら, iOS8 ステータスバー対策
From iOS8, there are no status bar when landscape in iPhone. (iPad still has)
If you change iOS SDK and application run with iOS8, status bar disappears.

You need to calculate in your code

If you use storyboard, xib, you don’t need to do anything.
But, if you create UI programmatically, you need to change your code.

Sample Code(swift)

import UIKit
 
let kHEADERHEIGHT : CGFloat = 44.0
 
class ViewController: UIViewController {
     
    var headerView : UIView
    var borderView : UIView
     
    override init() {
        self.headerView = UIView()
        self.borderView = UIView()
        super.init()
    }
     
    override init(nibName nibNameOrNil: String?, bundle nibBundleOrNil: NSBundle?){
        self.headerView = UIView()
        self.borderView = UIView()
        super.init(nibName: nibName, bundle: nibBundle)
    }
 
    required init(coder aDecoder: NSCoder) {
        self.headerView = UIView()
        self.borderView = UIView()
        super.init(coder: aDecoder)
    }
 
    override func viewDidLoad() {
        super.viewDidLoad()
         
        self.view.backgroundColor = UIColor.whiteColor()
        
        self.headerView.backgroundColor = UIColor.cyanColor()
         
        self.borderView.backgroundColor = UIColor.grayColor()
         
        self.view.addSubview(self.headerView)
        self.view.addSubview(self.borderView)
    }
 
    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }
 
    override func viewWillLayoutSubviews() {
         
        let statusBarHeight = UIApplication.sharedApplication().statusBarFrame.height
        self.headerView.frame = CGRectMake(0, statusBarHeight, self.view.frame.size.width, kHEADERHEIGHT)
        self.borderView.frame = CGRectMake(0, statusBarHeight + kHEADERHEIGHT, self.view.frame.size.width, 0.5)
    }
}

The key point is to calculate status bar in viewWillLayoutSubviews.

CGRect statusbarFrame = UIApplication.sharedApplication().statusBarFrame

Result

statusbar portrait

statusbar landscape