LoginSignup
8
8

More than 5 years have passed since last update.

iPhone Xの角丸スクリーンの判定

Last updated at Posted at 2017-10-16

iPhone Xのスクリーンは長方形ではない。角丸になって上がへっこんでいる。
これに対応をするために長方形か、それともiPhone Xのような画面であるかの判定をしたい(たまにはそんなこともあろう)。

判定にはwindowのsafeAreaInsetsをつかって、これが0であれば長方形、0でなければiPhone Xのような形のはずだ。

func isiPhoneXScreen() -> Bool {
    guard #available(iOS 11.0, *) else {
        return false
    }

    return UIApplication.shared.windows[0].safeAreaInsets != UIEdgeInsets.zero
}

(iPhone Xの次はどんな形になるのかよくわからんので、来たら対応にするしかないな。。。)

this3.png

8
8
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
8
8