UISheetPresentationController

Panther·2021년 10월 11일
0

https://developer.apple.com/documentation/uikit/uisheetpresentationcontroller

"A presentation controller that manages the appearance and behavior of a sheet."

시트의 모양 및 동작을 관리하는 프리젠테이션 컨트롤러입니다.

Declaration

@MainActor class UISheetPresentationController : UIPresentationController

Overview

UISheetPresentationController는 뷰 컨트롤러를 시트로 나타날 수 있도록 해줍니다. 뷰 컨트롤러를 제시하기 전, 시트에 원하는 동작 및 모양을 갖도록 하고 뷰 컨트롤러의 sheetPresentationController 속성에 시트 프리젠테이션 컨트롤러를 설정하시기 바랍니다.

// In a subclass of UIViewController, customize and present the sheet.
func showMyViewControllerInACustomizedSheet() {
    let viewControllerToPresent = MyViewController()
    if let sheet = viewControllerToPresent.sheetPresentationController {
        sheet.detents = [.medium(), .large()]
        sheet.largestUndimmedDetentIdentifier = .medium
        sheet.prefersScrollingExpandsWhenScrolledToEdge = false
        sheet.prefersEdgeAttachedInCompactHeight = true
        sheet.widthFollowsPreferredContentSizeWhenEdgeAttached = true
    }
    present(viewControllerToPresent, animated: true, completion: nil)
}

시트 프리젠테이션 컨트롤러는 시트가 자연스럽게 남도록 하는 높이인 detent에 기반해 시트의 크기를 구체화합니다. detent는 시트가 다른 세 가지 edge가 고정되어 있는 동안 전체로 확장된 프레임의 한 edge로부터 크기를 재조정할 수 있도록 해줍니다. 시트가 detent를 사용하도록 지원하는 detent를 구체화할 수 있으며, selectedDetentIdentifier를 사용해서 최근에 선택된 detent를 모니터링할 수 있습니다.

Related Sessions from WWDC21
Session 10063: Customize and Resize Sheets in UIKit

Customize and Resize Sheets in UIKit
https://developer.apple.com/videos/play/wwdc2021/10063/

See Also


Presentation Management

UIPresentationController


0개의 댓글