Help us understand the problem. What is going on with this article?

【備忘録】Swiftで機種に応じてデザインを変える

機種に応じてデザインを変更する

機種ごとの画面サイズに応じたことをしたい時に、どうぞ。viewDidLoadの時点でも動くよ。(一応、どうしても身近に愛用している人がいなかったiPhone XS Maxを除き、実機テストで確認済み)

あ、機種ごとの性能の違いを考えて機種に応じた動作をさせたい時はこの方法はやめたほうがいい。

        //画面の高さ(ピクセル)で分けた
        print(UIScreen.main.nativeBounds.height)

        switch (UIScreen.main.nativeBounds.height) {

        case 1136:
            // iPhone 5, iPhone 5s, iPhone 5c, iPhone SE
            break

        case 1334:
            // iPhone 6, iPhone 6s, iPhone 7, iPhone 8
            break

        case 1920:
            // iPhone 6 Plus, iPhone 6s Plus, iPhone 7 Plus, iPhone 8 Plus
            break

        case 2436:
            //iPhone X,iPhone XS
            break

        case 1792:
            //iPhone XR
            break

        case 2688:
            //iPhone XS Max
            break

        default:
            break

        }
Why do not you register as a user and use Qiita more conveniently?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
Comments
Sign up for free and join this conversation.
If you already have a Qiita account
Why do not you register as a user and use Qiita more conveniently?
You need to log in to use this function. Qiita can be used more conveniently after logging in.
You seem to be reading articles frequently this month. Qiita can be used more conveniently after logging in.
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away