Change the Font of a Datepicker

Change the font of a DatePicker

It is not good to Customise the UIDatePicker

Although it is suggested to use the Native(Default) UIDatePicker of the Swift,

then also if anyone wants you can refer the following list

Following are some of the Customisable Datepicker from GitHub.

  1. https://github.com/squimer/DatePickerDialog-iOS-Swift
  2. https://github.com/itsmeichigo/DateTimePicker
  3. https://github.com/hsylife/SwiftyPickerPopover
  4. https://github.com/EngrAhsanAli/AAPickerView
  5. https://github.com/dillidon/alerts-and-pickers
  6. https://github.com/hughbe/day-date-picker
  7. https://github.com/alikaragoz/AIDatePickerController
  8. https://github.com/CooperRS/RMDateSelectionViewController
  9. https://github.com/zhhlmr/ZHDatePicker
  10. https://github.com/GasimGasimzada/FxDatePicker
  11. https://github.com/anatoliyv/SMDatePicker
  12. https://github.com/MarioIannotta/MIDatePicker

Note: But yes do not Try to customise The appearance of UIDatePicker.As it might make a danger of rejection of your app in
future.

Hope this helps.

Changing font color of Date Picker with inline style

There is no way to change inline styled Date Picker text color in UIKit 14, but here is a workaround you can try:

Override style

I noticed that if you change the theme of the device (between light and dark), the text color of the .inline date picker is changing.
So for example if you want a dark-text date picker in dark theme, you can override it:

myDatePicker.overrideUserInterfaceStyle = .light

Heres a image of the result

image

I will keep this post updated if there is any new way to change to any color.

How can I change font size of the dates within the datepicker (SwiftUI)

You can apply a .transformEffect(.init(scaleX: 0.7, y: 0.7)):

var body: some View {
ZStack {
Color(.purple).edgesIgnoringSafeArea(.all)
VStack {
Section {
DatePicker("Event Date", selection: $eventDate, in: ...Date())
.labelsHidden()
.transformEffect(.init(scaleX: 0.7, y: 0.7))
}
}
}
}

How to change the font color of month and year picker in jquery datepicker?

Problem : There is white color in month & year drop down list in jQuery UI datepicker

Solution :

  • jQuery UI's default color is #333 for Year & Month drop down, so here it is 100% change, that some other class is overwriting that default color
  • You need to change .ui-datepicker select.ui-datepicker-month and .ui-datepicker select.ui-datepicker-year color to as per your
    requirement like color:#000!important;

  • Make sure this newly written class must applied only after jQuery UI css file imported.

  • Use developer toolbar to verify that new css is applying or overwriting by something else.

Check below example, Year and Month's drop down color is changed by red using css only:

  $( function() {        $( "#datepicker" ).datepicker({      changeMonth: true,      changeYear: true    });  } );
.ui-datepicker select.ui-datepicker-month,.ui-datepicker select.ui-datepicker-year {    color:red!important;}
  <link rel="stylesheet" href="//code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css">  <link rel="stylesheet" href="/resources/demos/style.css">  <script src="https://code.jquery.com/jquery-1.12.4.js"></script>  <script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script>    <P>Click on the textbox, see that Month & Year drop down color is changed!</p>  <input type="text" id="datepicker">

Change font color in new DatePicker (iOS14)

I don't have your colors but the following should work.

Tested with Xcode 12.1 / iOS 14.1

demo

VStack (alignment: .center, spacing: 0)
{
DatePicker(selection: self.$enddate, in: self.endMinDate()...self.endMaxDate()) {
Text("Start")
}.labelsHidden()
}
.accentColor(MyColor.bluecolor) // << this one !!
//.accentColor(.red) // << used for demo

MUI DatePicker default textfield cannot be customized with different font color and size

All you had to do was inspect the text, copy the applicable classname and apply classes.root directly to .

Sample Image

const useStyles = makeStyles({
root: {
"& .MuiOutlinedInput-input": {
border: 0,
borderRadius: 3,
color: "red",
fontSize: 24
}
}
});

const DateSettings() {
const classes = useStyles();
const [value, setValue] = useState(Date | (null > null));

return (
<Box>
<LocalizationProvider dateAdapter={AdapterDateFns}>
<Stack spacing={3}>
<MobileDatePicker
inputFormat="MM/dd/yyyy"
value={value}
onChange={handleChange}
components={{ OpenPickerIcon: CalendarIcon }}
renderInput={(params) => <TextField className={classes.root} {...params} />}
/>
</Stack>
</LocalizationProvider>
</Box>
);
}

Sample Image

Change fontcolor of DatePicker Android

EDIT2: This works. (Added divider color)

Your XML

<DatePicker
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/datePicker"
android:calendarViewShown="false"
android:spinnersShown="true"
android:datePickerMode="spinner"
android:layout_below="@+id/tb_register_last_name"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_alignRight="@+id/bt_register_tostep3"
android:layout_alignEnd="@+id/bt_register_tostep3"
android:theme="@style/MyDatePicker"/>

In styles.xml, set this (copy-paste the code)

<style name="MyDatePicker" parent="Theme.AppCompat.Light.Dialog.Alert">
<item name="colorControlNormal">#00FF00</item>
<item name="colorControlActivated">#00FF00</item>
<item name="android:textColorPrimary">#FF0000</item>
</style>

Google materialdoc will be helpful for you in the future.

Change your style and let me know if it works!!



Related Topics



Leave a reply



Submit