LoginSignup
2
2

More than 5 years have passed since last update.

[Swift 3] 画面サイズ statusBar navigationBar tabBar の高さ・幅を取得する

Last updated at Posted at 2017-06-25

目的

以前調べた取得方法だと構文エラーが出たのでSwift3用に書いた

コード

DeviceSize.swift
import UIKit


struct DeviceSize {
    static let bounds = UIScreen.main.bounds
    static let screenWidth = UIScreen.main.bounds.size.width
    static let screenHeight = UIScreen.main.bounds.size.height
    static let statusBarHeight = UIApplication.shared.statusBarFrame.height
    static let navigationBarHeight = { (navigationController: UINavigationController) -> CGFloat in
        return navigationController.navigationBar.frame.size.height
    }
    static let tabBarHeight = { (tabBarController: UITabBarController) -> CGFloat in
        return tabBarController.tabBar.frame.size.height
    }
}

2
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
2