LoginSignup
6
4

More than 5 years have passed since last update.

アプリの表示領域のサイズを取得する

Last updated at Posted at 2016-11-28

画面サイズを取得する

画面のサイズは以下のように取得する。

 let screenSize = UIScreen.main.bounds

ウィンドウサイズを取得する

実際のアプリケーションの表示領域のサイズを取得したい場合は以下

let windowSize = UIApplication.shared.keyWindow?.bounds

windowのサイズはviewDidAppear以降でないと取得できなかった。

iPadに対応したアプリケーションを作る場合、マルチタスク機能が存在し、ScreenサイズとWindowサイズが等しくない場合があるため、アプリの表示領域のサイズを知りたい場合はWindowサイズを取得すると良い。

6
4
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
6
4