UIModalPresentationStyle.FormSheet in Xamarin.Forms
A pull request I created has just been merged into Xamarin.Forms! It is a small change, but I thought I’d let you know. You are now able to set the modal presentation to UIModalPresentationStyle.FormSheet for iOS, causing the modal to be opened as a popup on iPad.
At the time of writing, the PR has just been merged, so it isn’t in the NuGet packages yet, but it will be in the next release!
How to use the new UIModalPresentationStyle.FormSheet #
Using this new feature is easy.
Simply call the new platform-specific method:
On().SetModalPresentationStyle(UIModalPresentationStyle.FormSheet);
You can do this either in the constructor of the page you want to show modally, or when you create the page in a variable and call it upon the variable that holds the instance.
Please note that this only works on iPad. Although the property is set on iPhone, it does not have any effect since Apple chose not to support it there.
Background #
This feature is very platform-specific and that is why it is implemented through the On method. Through this extension method, we set the new presentation mode, which is then handled in a wrapper object for Xamarin.Forms. Then, whenever the page is shown modally, iOS will take over and show the page as a form sheet. There are a whole set of other platform-specific calls you can do for either iOS, Android or Windows.
Result #
The result when showing the modal screen as a form sheet can be seen in the screen below. This screenshot is taken from the sample app in the Xamarin.Forms repository, which is used to test out new features.
Contributing to Xamarin.Forms yourself #
The most awesome thing is, you can contribute yourself! Just head over to the repository and check out the issues that are open right now. You can pick up one of those, or if you have a whole new idea: open an issue yourself. The latter is recommended instead of just diving in, the team at Xamarin is not just going to accept all PRs, so it is worth while to check with them first if your idea is a good one.