1

The Xamarin.Forms DatePicker on iOS brings up a popup picker at the bottom of the screen when tapped, as shown in the following image:

enter image description here

Unfortunately when the user swipes down to change the date quickly, this can trigger the Reachability feature where the app slides down so the top half of the screen is easier to reach. I understand that this is an operating system-level feature and that iOS users may be familiar with it, but I would like to modify my app to make it a little more user friendly.

One solution might be to move the popup higher so there's less of a chance of swiping off the bottom of the screen, as shown in the following mock screenshot:

enter image description here

Is this possible using Xamarin.Forms or with some type of DatePicker renderer? I know I can modify the DatePicker itself with a renderer, but I'm not sure if I can modify the popup window.

Update 1

This post also discusses a similar topic - how to disable the Reachability feature for an app:

Disable iOS Reachability Swipe Gesture in iOS game

Unfortunately the current (as of January 17, 2022) conclusion is that there is a bug which makes this particular call broken, so attempting to solve the problem by disabling Reachability in code is currently not possible using this method.

Victor Chelaru
  • 4,491
  • 3
  • 35
  • 49

1 Answers1

0

Try to following code .

[assembly: ExportRenderer(typeof(DatePicker), typeof(MyPickerRenderer))]
namespace MyForms.iOS
{
    internal class MyPickerRenderer : DatePickerRenderer
    {
        protected override void OnElementPropertyChanged(object sender, PropertyChangedEventArgs e)
        {
            base.OnElementPropertyChanged(sender, e);


            var frame1 = Control.InputAccessoryView.Frame;
            frame1.Y = -100;
            Control.InputAccessoryView.Frame = frame1;

            var frame2 = Control.InputView.Frame;
            frame2.Y = -100;
            Control.InputView.Frame = frame2;
        }
    }
}

There is a small problem , the popup picker will reset the location(bottom) if it loses focus .

enter image description here

ColeX
  • 14,062
  • 5
  • 43
  • 240