티스토리 뷰
728x90
반응형
UIDevice 를 extension 으로 아이폰의 기종유무를 저장하는 변수를 만든다.
import UIKit
extension UIDevice {
public var isiPhoneSE: Bool {
if UIDevice.current.userInterfaceIdiom == UIUserInterfaceIdiom.phone && (UIScreen.main.bounds.size.height == 568 && UIScreen.main.bounds.size.width == 320) {
return true
}
return false
}
public var isiPhoneSE2: Bool {
if UIDevice.current.userInterfaceIdiom == UIUserInterfaceIdiom.phone && (UIScreen.main.bounds.size.height == 667 && UIScreen.main.bounds.size.width == 375) {
return true
}
return false
}
public var isiPhone8Plus: Bool {
if UIDevice.current.userInterfaceIdiom == UIUserInterfaceIdiom.phone && (UIScreen.main.bounds.size.height == 736 || UIScreen.main.bounds.size.width == 414) {
return true
}
return false
}
public var isiPhone12mini: Bool {
if UIDevice.current.userInterfaceIdiom == UIUserInterfaceIdiom.phone && (UIScreen.main.bounds.size.height == 812 && UIScreen.main.bounds.size.width == 375) {
return true
}
return false
}
public var isiPone12Pro: Bool {
if UIDevice.current.userInterfaceIdiom == UIUserInterfaceIdiom.pad && (UIScreen.main.bounds.size.height == 844 && UIScreen.main.bounds.size.width == 390) {
return true
}
return false
}
}
view controller 에서 다음과 같이 기기대응을 할 수 있다.
// MARK: - UIComponents
@IBOutlet weak var customNavigationBarViewHeight: NSLayoutConstraint!
@IBOutlet weak var progressBarLeftAnchor: NSLayoutConstraint!
@IBOutlet weak var indexLeftAnchor: NSLayoutConstraint!
@IBOutlet weak var indexRightAnchor: NSLayoutConstraint!
@IBOutlet weak var guideLabel1LeftAnchor: NSLayoutConstraint!
@IBOutlet weak var guideLabel1BottomAnchor: NSLayoutConstraint!
@IBOutlet weak var guideLabel1TopAnchor: NSLayoutConstraint!
@IBOutlet weak var genderListCollectionViewTopAnchor: NSLayoutConstraint!
@IBOutlet weak var genderListCollectionViewLeftAnchor: NSLayoutConstraint!
@IBOutlet weak var genderListCollectionViewRightAnchor: NSLayoutConstraint!
@IBOutlet weak var guideLable3TopAnchor: NSLayoutConstraint!
@IBOutlet weak var nextButtonBottomAnchor: NSLayoutConstraint!
@IBOutlet weak var genderListCollectionViewRatio: NSLayoutConstraint!
override func viewDidLoad() {
super.viewDidLoad()
setPhoneResolution()
}
func setPhoneResolution(){
if UIDevice.current.isiPhoneSE2 {
customNavigationBarViewHeight.constant = 50
progressBarLeftAnchor.constant = 16
indexLeftAnchor.constant = 9
indexRightAnchor.constant = 18
guideLabel1TopAnchor.constant = 29
guideLabel1LeftAnchor.constant = 16
guideLabel1BottomAnchor.constant = 6
genderListCollectionViewTopAnchor.constant = 15
genderListCollectionViewLeftAnchor.constant = 11
genderListCollectionViewRightAnchor.constant = 11
guideLable3TopAnchor.constant = 31
nextButtonBottomAnchor.constant = 28
}
728x90
반응형
'iOS' 카테고리의 다른 글
iOS) Splash 화면에서 로그인 분기처리하기 (0) | 2021.07.23 |
---|---|
iOS) 서버통신 시 데이터모델에서 데이터부분 옵셔널 처리 (0) | 2021.07.23 |
iOS) viewDidAppear() 에서 화면전환 코드 작성하기 (0) | 2021.07.23 |
iOS) 제플린에서 쉐도우 설정 및 동적으로 셀크기 설정 (0) | 2021.07.23 |
iOS) 서버와 HTTP 통신을 위한 Xcode 설정 (0) | 2021.07.22 |
댓글
TAG
- SwiftUI
- IOS
- async/await
- watchOS
- YPImagePicker
- rxswift
- configurable widget
- urlsession
- Notification
- WWDC22
- WidgetKit
- OpenSourceLibrary
- MVVM
- UserDefaults
- RxCocoa
- github
- containerBackground
- WWDC
- CloneCoding
- 서버통신
- APNS
- Protocol
- Algorithm
- projectsetting
- MOYA
- Widget
- Firebase
- Swift
- 2022 KAKAO TECH INTERNSHIP
- Objective-C
최근에 올라온 글
최근에 달린 댓글
글 보관함
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 | 31 |
링크
- Total
- Today
- Yesterday