4
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

【Swift】nativeBoundsについて

4
Last updated at Posted at 2018-11-14

知らなかったのでメモ。

画面の向きにかかわらず、いつでもportrait時のboundsが取得できるプロパティ
nativeBounds - UIScreen | Apple Developer Documentation

例)portraitだけではなくlandscapeにもなるiPadアプリで、スクリーンの高さによって制約を変えたいときのコード

     
switch (UIScreen.main.nativeBounds.height) {
case 2048: // 9.7インチ
    viewWidthConstraint.constant = 768
case 2224: // 10.5インチ
    viewWidthConstraint.constant = 834
case 2732: // 12.9インチ
    viewWidthConstraint.constant = 1024
default:
    viewWidthConstraint.constant = 768
}
4
1
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
4
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?