Skip to content

Instantly share code, notes, and snippets.

@Thunor
Forked from hjerpbakk/TimePicker24HRenderer.cs
Created June 15, 2017 16:51
Show Gist options
  • Save Thunor/3b71a43de1e6bd9de64a2a4ef43316b3 to your computer and use it in GitHub Desktop.
Save Thunor/3b71a43de1e6bd9de64a2a4ef43316b3 to your computer and use it in GitHub Desktop.
Custom renderer for Xamarin.Forms TimePicker on iOS. This will make the TimePicker always show time using 24H format (aka no AM or PM).
using MonoTouch.Foundation;
using MonoTouch.UIKit;
using Xamarin.Forms;
using Xamarin.Forms.Platform.iOS;
using PersonalTrainer.iOS.View.Controls;
[assembly: ExportRenderer (typeof (TimePicker), typeof (TimePicker24HRenderer))]
namespace YourNamespace.iOS.View.Controls {
public class TimePicker24HRenderer : TimePickerRenderer {
protected override void OnElementChanged(ElementChangedEventArgs<TimePicker> e) {
base.OnElementChanged(e);
var timePicker = (UIDatePicker)Control.InputView;
timePicker.Locale = new NSLocale("no_nb");
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment