Add AM/PM to datepicker?

强颜欢笑 提交于 2019-12-01 18:03:41

This will depend on the settings of the user. If you go to Settings -> General -> Date & Time. there is a "24-Hour" time switch, and based on that users will have the AM/PM indicator on your picker.

Unfortunately UIDatePicker doesn't have an option for that; it always respects the device option of 12-hour or 24-hour time.

If you must have an AM/PM component you may have to go with a custom UIPickerView instead, and build an NSDate out of its components manually.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!