Programing

iPhone X의 상단 막대 높이는 얼마입니까?

즐거운 cyworld 2021. 1. 10. 16:46
반응형

iPhone X의 상단 막대 높이는 얼마입니까?


iPhone X 상단 표시 줄의 정확한 높이를 알고 싶습니다. iPhone X의 상태 표시 줄과 탐색 표시 줄 높이를 말씀해 주시겠습니까? 도와주세요.

여기에 이미지 설명 입력


그러나 iPhone X의 디스플레이 는 4.7 인치 디스플레이보다 145pt 더 커서 콘텐츠를위한 추가 세로 공간이 약 20 %가됩니다.

자세한 내용 여기 1여기 2의 애플 문서 및 세부 설명에서 iphone X 용 HIG를 얻습니다.

여기에 이미지 설명 입력

상태 표시 줄 높이

이전에는 20pt, 현재는 44pt

Because of the sensors on top of the display, the new status bar is split in 2 parts. If your UI is doing something special with that space (previously 20pt high, now 44pt), because it will be taller on the iPhone X. Make sure that it can be dynamically changed in height. A great thing is that the height won’t be changed if a user makes a phone call or is using a navigation app, which was previously the case on other iPhones.

여기에 이미지 설명 입력

portrait

Navigation bar height as normal 88 and large title time 140

  • Standard title - 44pt (88pt with Status Bar)
  • Large title - 140pt
  • bottom bar - 34pt

Landscape

  • Standard title - 32pt
  • bottom bar - 21pt

Nav bar is 44pt as usual (when no large titles) and the status bar has increased from 20pt to 44pt. Here's what you can type in the debugger to verify it:

여기에 이미지 설명 입력


You can programmatically obtain the navigation bar's height by using safeAreaInsets on the view in the contained view controller:

let navBarHeight = view.safeAreaInsets.top

This will account for whether it's a large title navigation bar or not, and whether or not there's a search bar attached to it.

See the safeAreaInsets documentation for more information.


You can simply get it in the next way (Swift 3):

let barHeight = navigationController?.navigationBar.frame.maxY

To get correct value make sure that you call it after setting prefersLargeTitles

navigationController?.navigationBar.prefersLargeTitles = false

You can use the navigation bar's .frame property to figure out the overall height of the top bar area:

ObjC:

CGRect navbarFrame = self.navigationController.navigationBar.frame;
float topWidth  = navbarFrame.size.width;
float topHeight = navbarFrame.size.height + navbarFrame.origin.y;

I suppose this is a bit of a cheat, but adding the navbar's height with its y origin seems to give the correct total height regardless of device.


There is no specification in Apple Docs

Apple Docs

According to Geoff Hackworth its 88

탐색 제목 유형 :

  • 표준 제목
  • 큰 제목

iOS 11에서 내비게이션 바 늘리기

navigationController?.navigationBar.prefersLargeTitles = true

시작 내용이 필요한 곳을 알고 싶다면 사용하십시오.

extension UIViewController {
  var navigationBarbarContentStart: CGFloat {
    return self.navigationBarTopOffset + self.navigationBarHeight
  }
  var navigationBarTopOffset: CGFloat {
    return self.navigationController?.navigationBar.frame.origin.y ?? 0
  }

  var navigationBarHeight: CGFloat {
    return self.navigationController?.navigationBar.frame.height ?? 0
  }
}

참조 URL : https://stackoverflow.com/questions/46197660/what-is-the-top-bar-height-of-iphone-x

반응형