일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | ||||||
2 | 3 | 4 | 5 | 6 | 7 | 8 |
9 | 10 | 11 | 12 | 13 | 14 | 15 |
16 | 17 | 18 | 19 | 20 | 21 | 22 |
23 | 24 | 25 | 26 | 27 | 28 | 29 |
30 |
Tags
- CryptoSwift
- RxSwift
- archive error
- then
- MVVM
- RxCocoa
- color 변경
- testflight error
- navigationbar
- codebase
- 비공개 앱 배포
- Business Manager
- 테이블뷰 밀어서 삭제
- 테이블뷰 셀 밀어서 삭제
- 로그출력
- AppleLogin
- 스토리보드 없이
- iOS 광고달기
- 화면 가리기
- 소셜로그인
- 아카이브 에러
- 하단 네비게이션바
- reactorkit
- 백그라운드 진입시 화면
- 테이블 뷰
- print vs dump
- 로그 찍기
- Apple Enterprise
- snapkit
- failed: No such file or directory (2)
Archives
- Today
- Total
ukSeung iOS
[Swift] Get DeviceModel Name, 디바이스 모델명 가져오기 본문
안녕항셍용 욱승임다
시뮬레이터에 이어서 디바이스 모델명 가져오는 코드를 작성해보겠슴당
시뮬레이터, 실제 기기에서도 작동 되는 코드임!
2023년 9월 기준 아이폰 15 시리즈가 나왔습니다.
width와 height값은 공식 홈페이지에 있으니 case로 추가해 디바이스 모델명을 가져올수 있습니다
함수
func getDeviceModelName() -> String {
let screenWidth = UIScreen.main.bounds.size.width
let screenHeight = UIScreen.main.bounds.size.height
switch (screenWidth, screenHeight) {
case (320, 480):
return "iPhone 3GS"
case (320, 480):
return "iPhone 4 or iPhone 4s"
case (320, 568):
return "iPhone 5, iPhone 5c, iPhone 5s, or iPhone SE (1st Gen)"
case (375, 667):
return "iPhone 6, iPhone 6s, iPhone 7, iPhone 8, iPhone SE (2nd Gen)"
case (375, 812):
return "iPhone 12 mini, iPhone 13 mini"
case (414, 736):
return "iPhone 6 Plus, iPhone 6s Plus, iPhone 7 Plus, iPhone 8 Plus"
case (375, 812):
return "iPhone X, iPhone XS, iPhone 11 Pro"
case (414, 896):
return "iPhone XR, iPhone 11"
case (390, 844):
return "iPhone 12, iPhone 12 Pro, iPhone 13, iPhone 13 Pro, iPhone 14"
case (393, 852):
return "iPhone 14 Pro"
case (414, 896):
return "iPhone XS Max, iPhone 11 Pro Max"
case (428, 926):
return "iPhone 12 Pro Max, iPhone 13 Pro Max, iPhone 14 Plus"
case (430, 932):
return "iPhone 14 Pro Max"
case (1024, 768):
return "iPad, iPad Mini"
case (1112, 834):
return "iPad Pro 10.5 inch, iPad Air"
case (1194, 834):
return "iPad Pro 11 inch"
case (1366, 1024):
return "iPad Pro 12.9 inch"
default:
return "Unknown"
}
}
구현부
let deviceModel = getDeviceModelName() // 함수 호출로 간단하게 String값을 가져올수 있음
print(deviceModel) // iPhone 14 Pro Max
728x90
반응형
'iOS > Swift' 카테고리의 다른 글
[Swift] 앱 빌드 오류, failed: Operation not permitted (1) (2) | 2023.11.29 |
---|---|
[Swift] RxSwift + MVVM, FaceID & TouchID authentication (0) | 2023.10.05 |
[Swift] 시뮬레이터 디바이스 모델명 가져오기 / Get Simulator IPhone Model Name (0) | 2023.08.25 |
[Swift] 화면이동시 SafeArea Background Color이 변경 되는 이슈 (2) | 2023.06.20 |
[Swift] Hotspot Configuration, 핫스팟 연결 (1) | 2023.05.24 |