일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |
- 다이어리
- libasm
- 리눅스
- DBMS
- CI
- javascript
- 스프링부트
- 42seoul
- 오블완
- Spring
- 스프링
- 소켓
- 아이패드다이어리
- Xcode
- 오라클
- jenkins
- 프로그래밍언어론
- IOS
- 스프링부트 웹 소켓
- sql
- swift
- 티스토리챌린지
- 데이터베이스
- 인공지능
- JPA
- springboot
- MySQL
- CD
- AI
- 네트워크
- Today
- Total
Hi yoahn 개발블로그
[iOS] safeArea 사용하기 본문
study 를 진행하면서 ImageView의 레이아웃을 잡아야 했는데, 위치를 잡는 과정에서 iPhone X 이상 모델에서 노치로 인한 SafeArea 위치를 파악하여 safeArea에 view를 잡는 과정이 필요했는데, 드디어 알아내서 기록해두려고 한다
먼저 Swift - iOS 13.0 이상
let window = UIApplication.shared.windows[0]
let topPadding = window.safeAreaInsets.top
let bottomPadding = windows.safeAreaInsets.bottom

topPadding 은 위 사진에서 상단에 위치한 녹색 영역의 높이를 나타내고,
bottomPadding 은 위의 사진에서 하단에 위치한 녹색 영역의 height 크기를 의미한다.
변수에 저장한 padding 값을 코드로 뷰의 위치를 지정할 때 사용하면 된다.
stackoverflow.com/questions/46829840/get-safe-area-inset-top-and-bottom-heights/53864017#53864017
Get safe area inset top and bottom heights
On the new iPhone X, what would be the most proper way to get both top and bottom height for the unsafe areas?
stackoverflow.com
devmjun.github.io/archive/SafeArea_1
Swift, Safe Area에 대해서 알아봅니다.
devmjun.github.io
위 링크에 나오는 내용들은 적용이 안되는 것 같은데 댓글로 알려주시면 감사합니다:)
'프로그래밍 언어 > iOS' 카테고리의 다른 글
[iOS] constraint, stackview (0) | 2021.02.20 |
---|---|
[iOS] view layout 잡기 (0) | 2021.02.08 |
[iOS] 비율에 맞춰서 이미지 표시하기 (0) | 2021.01.26 |
[iOS] View Controller의 생명주기 (Life-Cycle) (0) | 2021.01.25 |
[iOS] 화면 전환 방법 (0) | 2021.01.25 |