@@ -81,8 +81,7 @@ export class DateTimePicker extends DateTimePickerBase {
81
81
pickerContainerFrameTop += DateTimePicker . PICKER_DEFAULT_TITLE_HEIGHT ;
82
82
}
83
83
const pickerViewHeight = DateTimePicker . PICKER_DEFAULT_MESSAGE_HEIGHT ;
84
- const pickerContainerFrame = CGRectMake ( 0 , pickerContainerFrameTop , pickerViewWidth , pickerViewHeight ) ;
85
- const pickerContainer = UIView . alloc ( ) . initWithFrame ( pickerContainerFrame ) ;
84
+ const pickerContainer = UIView . alloc ( ) . init ( ) ;
86
85
let spinnersBackgroundColor = new Color ( "transparent" ) ;
87
86
let spinnersTextColor = null ;
88
87
if ( style ) {
@@ -94,12 +93,22 @@ export class DateTimePicker extends DateTimePickerBase {
94
93
const pickerView = nativePicker ;
95
94
pickerView . frame = CGRectMake ( 0 , 0 , pickerViewWidth , pickerViewHeight ) ;
96
95
pickerContainer . addSubview ( pickerView ) ;
96
+ DateTimePicker . _clearVibrancyEffects ( alertController . view ) ;
97
97
98
98
const messageLabel = DateTimePicker . _findLabelWithText ( alertController . view , DateTimePicker . PICKER_DEFAULT_MESSAGE ) ;
99
- const messageLabelContainer = messageLabel . superview ;
99
+ const messageLabelContainer = DateTimePicker . _getLabelContainer ( messageLabel ) ;
100
100
messageLabelContainer . clipsToBounds = true ;
101
101
messageLabelContainer . addSubview ( pickerContainer ) ;
102
102
103
+ pickerContainer . translatesAutoresizingMaskIntoConstraints = false ;
104
+ pickerContainer . topAnchor . constraintEqualToAnchorConstant ( alertController . view . topAnchor , pickerContainerFrameTop ) . active = true ;
105
+ pickerContainer . leftAnchor . constraintEqualToAnchor ( alertController . view . leftAnchor ) . active = true ;
106
+ pickerContainer . rightAnchor . constraintEqualToAnchor ( alertController . view . rightAnchor ) . active = true ;
107
+ pickerContainer . bottomAnchor . constraintEqualToAnchor ( alertController . view . bottomAnchor ) . active = true ;
108
+
109
+ pickerView . leftAnchor . constraintLessThanOrEqualToAnchorConstant ( pickerContainer . leftAnchor , DateTimePicker . PICKER_WIDTH_INSETS ) . active = true ;
110
+ pickerView . rightAnchor . constraintLessThanOrEqualToAnchorConstant ( pickerContainer . rightAnchor , DateTimePicker . PICKER_WIDTH_INSETS ) . active = true ;
111
+
103
112
const cancelButtonText = options . cancelButtonText ? options . cancelButtonText : "Cancel" ;
104
113
const okButtonText = options . okButtonText ? options . okButtonText : "OK" ;
105
114
const cancelActionStyle = ( style && style . buttonCancelBackgroundColor ) ? UIAlertActionStyle . Default : UIAlertActionStyle . Cancel ;
@@ -169,6 +178,7 @@ export class DateTimePicker extends DateTimePickerBase {
169
178
}
170
179
if ( color ) {
171
180
nativePicker . setValueForKey ( color . ios , "textColor" ) ;
181
+ nativePicker . setValueForKey ( false , "highlightsToday" ) ;
172
182
}
173
183
}
174
184
@@ -201,6 +211,25 @@ export class DateTimePicker extends DateTimePickerBase {
201
211
}
202
212
}
203
213
214
+ private static _clearVibrancyEffects ( uiView : UIView ) {
215
+ if ( uiView instanceof UIVisualEffectView && uiView . effect instanceof UIVibrancyEffect ) {
216
+ // Since ios13 UIAlertController has some effects which cause
217
+ // semi-transparency and interfere with color customizations:
218
+ uiView . effect = null ;
219
+ }
220
+ const subViewsCount = uiView . subviews . count ;
221
+ for ( let i = 0 ; i < subViewsCount ; i ++ ) {
222
+ DateTimePicker . _clearVibrancyEffects ( uiView . subviews [ i ] ) ;
223
+ }
224
+ }
225
+
226
+ private static _getLabelContainer ( uiView : UIView ) {
227
+ if ( uiView . superview . class ( ) === ( UIView . class ( ) ) ) {
228
+ return uiView . superview ;
229
+ }
230
+ return DateTimePicker . _getLabelContainer ( uiView . superview ) ;
231
+ }
232
+
204
233
private static _findLabelWithText ( uiView : UIView , text : string ) {
205
234
if ( ( uiView instanceof UILabel ) && uiView . text === text ) {
206
235
return uiView ;
0 commit comments