目的
以前調べた取得方法だと構文エラーが出たので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
}
}