Safe Area
기기의 Safe Area Insets 정보를 조회하고 변경을 구독하는 API예요. 노치, 홈 인디케이터 등으로 가려지지 않는 영역을 계산할 때 사용해요.
API
| API | 반환 타입 | 설명 |
|---|---|---|
AIT.SafeAreaInsetsGet() | SafeAreaInsets | 현재 Safe Area Insets를 조회해요 |
AIT.SafeAreaInsetsSubscribe() | Action (구독 해제) | Safe Area Insets 변경을 구독해요 |
SafeAreaInsetsGet
현재 기기의 Safe Area Insets 값을 조회해요.
csharp
try
{
var insets = await AIT.SafeAreaInsetsGet();
Debug.Log($"Top: {insets.Top}, Bottom: {insets.Bottom}, Left: {insets.Left}, Right: {insets.Right}");
}
catch (AITException ex)
{
Debug.LogError($"Safe Area 조회 실패: {ex.Message}");
}SafeAreaInsetsSubscribe
Safe Area Insets가 변경될 때마다 콜백으로 알려줘요. 반환된 Action을 호출하면 구독을 해제할 수 있어요.
csharp
Action unsubscribe;
async void OnEnable()
{
unsubscribe = await AIT.SafeAreaInsetsSubscribe(new SafeAreaInsetsSubscribe__0
{
// 구독 옵션
});
}
void OnDisable()
{
unsubscribe?.Invoke();
}TIP
SafeAreaInsetsSubscribe는 구독 기반이므로OnDisable에서 반드시 구독을 해제해 주세요.- UI 레이아웃을 Safe Area에 맞출 때 활용하면 노치나 홈 인디케이터에 의해 콘텐츠가 가려지는 것을 방지할 수 있어요.