프로그래밍/iOS

아이폰 화면 해상도 알아내는 방법

Nexthops 2018. 8. 29. 19:57

아이폰 화면 해상도 알아내는 방법


cocoapods를 통해 'AssistantKit'을 설치한다.


이후 AssistantKit을 import 한다. 

let screen = Device.screen

        

        switch screen {

        case .inches_3_5:  print("3.5 inches")

        case .inches_4_0:  print("4.0 inches")

        case .inches_4_7:  print("4.7 inches")

        case .inches_5_5:  print("5.5 inches")

        case .inches_7_9:  print("7.9 inches")

        case .inches_9_7:  print("9.7 inches")

        case .inches_12_9: print("12.9 inches")

        default:           print("Other display")

        }


스크린 사이즈를 가지고 세부 레이아웃을 설정할 수 있다.


관련 사용방법은 아래 링크에서 직접 확인하면 된다. 


https://cocoapods.org/pods/AssistantKit