[Swift] UISheetPresentationController 뿌시기

물론 iOS 15 이상부터요 ◠‿◠

들어가기전에

let modalViewController = ModalViewController()
self.present(modalViewController, animated: true)
let modalViewController = ModalViewController()
modalViewController.modalPresentationStyle = .fullScreen
self.present(modalViewController, animated: true)
class ModalViewController: UIViewController {
override func viewDidLoad() {
if let sheetPresentationController = sheetPresentationController {
sheetPresentationController.detents = [.medium(), .large()]
}
}
}

높이 지정

detents

어느날 운명처럼 영어 잘하게 해주세요 아멘
var detents: [UISheetPresentationController.Detent] { get set }
  • large()전체 높이 로 system detent 를 생성
  • medium()— 스크린의 절반에 가까운 높이의 system detent 생성. compact height 에서는 비활성화 됨.
sheetPresentationController.detents = []
sheetPresentationController.detents = [.medium, .large()]
sheetPresentationController.detents = [.large, .medium()]
뒤에 있는 뷰가 좀 작아지는 상황

selectedDetentIdentifier

print(sheetPresentationController.selectedDetentIdentifier) // nil
gif 가 지연되어서 보이긴 하는데 님들이 생각하시는대로 뜨는 상황 맞음여

User interaction 관리

largestUndimmedDetentIdentifier

sheetPresentationController.largestUndimmedDetentIdentifier = .medium

prefersScrollingExpandsWhenScrolledToEdge

모양 관리

prefersGrabberVisible

없음 / 있음

preferredCornerRadius

prefersEdgeAttachedInCompactHeight

참고 — https://developer.apple.com/design/human-interface-guidelines/foundations/layout/

widthFollowsPreferredContentSizeWhenEdgeAttached

delegate 관리

UISheetPresentationControllerDelegate

func sheetPresentationControllerDidChangeSelectedDetentIdentifier(_:)

Sheet 변화에 대한 애니메이션 효과

animateChanges(_:)

sheetPresentationController.selectedDetentIdentifier = .medium
sheetPresentationController.animateChanges {
sheetPresentationController.selectedDetentIdentifier = .medium
}

마무리

출처

--

--

 https://github.com/sujinnaljin/TIL

Love podcasts or audiobooks? Learn on the go with our new app.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store