Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to detect dynamic-island size and changes in SwiftUI & UIKit

How can we detect the size and changes of the iPhone 14 pro dynamic-island?

Since the safe area provides a safe rectangle inside the rounded screen and top or bottom insets, but nothing about an object inside the rectangle.

The all we know about safe area:

enter image description here

like image 382
Mojtaba Hosseini Avatar asked Jan 30 '26 01:01

Mojtaba Hosseini


1 Answers

First of all for most developers it is sufficient to use safeArea as we did before, because dynamic island does not cover it (if not in expanded state). There are currently 3 states of dynamic island:

  1. Compact. In the Dynamic Island, the system uses the compact presentation when there’s only one Live Activity that’s currently active. compact state
  2. Minimal. When multiple Live Activities are active, the system uses the minimal presentation to display two of them in the Dynamic Island. One Live Activity appears attached to the Dynamic Island while the other appears detached.

minimal

  1. Expanded. When people touch and hold a Live Activity in a compact or minimal presentation, the system displays the content in an expanded presentation.

enter image description here

You can check each state if you use dynamic island yourself as part WidgetKit. Create a new widget extension if your app doesn’t already include one. Live Activities use WidgetKit functionality and SwiftUI for their user interface. For creating new Activities, please refer to Apple official documentation for Displaying live data with Live Activities. If you are not intending to use Activities, but want to somehow be aware of dynamic island available sizes, Apple provides as with Dynamic island size sheet included in Live Activities documentation :

dynamic island size sheet

Here is an attachment of how safeArea looks implemented with dynamic island:

safe are with dynamic island

like image 93
Mr.SwiftOak Avatar answered Feb 01 '26 17:02

Mr.SwiftOak