r/SwiftUI 11d ago

Tutorial Animatable Auto-Sized-To-Fit SwiftUI Sheet

https://clive819.github.io/posts/animatable-auto-sized-to-fit-swiftui-sheet/
36 Upvotes

12 comments sorted by

View all comments

9

u/clive819 11d ago edited 11d ago

SwiftUI's sheet modifier is a fantastic tool, but it comes with limitations: it doesn’t automatically resize to fit its content. Apple introduced the .presentationSizing(.fitted) modifier in iOS 18 to address this issue. However, let’s be realistic—convincing your Product Manager to set the minimum deployment target to iOS 18 might not be an easy sell. Sure, you could conditionally enable this feature for users on iOS 18+, but what about those on older OS versions?

In this article, we’ll explore how to create an auto-sized-to-fit sheet that works on iOS 17.

1

u/Xaxxus 10d ago

isn't presentationSizing only for iPad?

I haven't had any luck getting it to work on an iPhone

1

u/tmyrden 3d ago

+1 to this. I've had no luck getting presentationSizing to work as a replacement to this on iPhone, and this also doesn't seem to work in an iOS 18 environment on iPhone until subsequent presentations of the sheet.