Dynamic Island is master stroke from Apple in iOS 16. Tremendous look!
Dynamic Island is almost same as a widget setup. I will describe you the sample code to setup the Dynamic Island
Let’s Create Project
I have created a new project of SwiftUI which create a live activity and this activity is connected with Dynamic Island.
Live Activities display your appβs most current data on the iPhone Lock Screen and in the Dynamic Island.
Note: Following step is must required. Set YES in Supports Live Activities into your app’s info plist.
Create Attributes
Now I have created a sample attributes file which will help us to display content on the activity and dynamic island.
Add Widget
Now I have added a widget for the live activity which will be useful for dynamic island. For that I have added a widget extension.
Here LiveActivityExpandedViewSample
will display status when dynamic island is in expanded state and on lock screen of iPhone. ( iPhone 14 Pro π )
Dynamic Island have 4 areas in which I can display my content. i.e. center, leading, trailing and bottom as I have described in sample code above.
Request Activity
Now from main application I have created an activity which will display the dynamic island with live activity on lock screen.
Here is the output!
Sample Code
I have added this sample code on my GitHub.
Conclusion
This is only sample code for dynamic island there are lot more stuff to display live data on it.
Let me know if you have any questions, comments, or feedback β viaΒ Twitter.
Learn Something New. Share To The World.
Happy Coding π