@@ -8,6 +8,8 @@ namespace AI
8
8
[ Register ( "AIDatePickerController" ) ]
9
9
public class AIDatePickerController : UIViewController , IUIViewControllerAnimatedTransitioning , IUIViewControllerTransitioningDelegate
10
10
{
11
+ private UIEdgeInsets safeAreaInsets ;
12
+
11
13
public double AnimatedTransitionDuration { get ; set ; } = 0.4 ;
12
14
public UIDatePickerMode Mode { get ; set ; } = UIDatePickerMode . Date ;
13
15
public UIColor BackgroundColor { get ; set ; } = UIColor . White ;
@@ -31,7 +33,9 @@ public AIDatePickerController()
31
33
{
32
34
//this.ModalPresentationStyle = UIModalPresentationStyle.Custom;
33
35
this . ModalPresentationStyle = UIModalPresentationStyle . OverCurrentContext ;
34
- this . TransitioningDelegate = this ;
36
+ this . TransitioningDelegate = this ;
37
+
38
+ SetupSafeAreaInsets ( ) ;
35
39
}
36
40
37
41
@@ -165,9 +169,21 @@ public override void ViewDidLoad()
165
169
this . View . AddConstraints ( NSLayoutConstraint . FromVisualFormat ( "H:|-5-[DatePickerContainerView]-5-|" , 0 , null , views ) ) ;
166
170
this . View . AddConstraints ( NSLayoutConstraint . FromVisualFormat ( "H:|-5-[ButtonContainerView]-5-|" , 0 , null , views ) ) ;
167
171
168
- this . View . AddConstraints ( NSLayoutConstraint . FromVisualFormat ( "V:|[DismissButton][DatePickerContainerView]-10-[ButtonContainerView(40)]-5 -|" , 0 , null , views ) ) ;
172
+ this . View . AddConstraints ( NSLayoutConstraint . FromVisualFormat ( $ "V:|[DismissButton][DatePickerContainerView]-10-[ButtonContainerView(40)]-{ 5 + safeAreaInsets . Bottom } -|", 0 , null , views ) ) ;
169
173
}
170
174
175
+ private void SetupSafeAreaInsets ( )
176
+ {
177
+ if ( UIDevice . CurrentDevice . CheckSystemVersion ( 11 , 0 ) )
178
+ {
179
+ safeAreaInsets = UIApplication . SharedApplication . KeyWindow . SafeAreaInsets ;
180
+ }
181
+ else
182
+ {
183
+ safeAreaInsets = new UIEdgeInsets ( ) ;
184
+ }
185
+ }
186
+
171
187
public double TransitionDuration ( IUIViewControllerContextTransitioning transitionContext )
172
188
{
173
189
return AnimatedTransitionDuration ;
0 commit comments