如何在 iOS 中使用 DatePicker 只接受月份和年份 [英] How to accept only Month and Year using DatePicker in iOS
本文介绍了如何在 iOS 中使用 DatePicker 只接受月份和年份的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在使用 swift 构建一个应用程序,在该应用程序中,有一个字段用于接受借记卡的到期日期以进行支付.如何通过在 Swift 中使用 DatePicker 只接受月份和年份.
I am building an app using swift and in that app there is one field for accepting expiry date for Debit card for payment purpose. How can I accept only month and year by using DatePicker in Swift.
如果无法使用 datepicker,请提出任何其他方法.
If it is not possible using datepicker then please suggest any another way.
提前致谢.
推荐答案
Choice-1
目标 C
yourDatepicker.datePickerMode = UIDatePickerModeDate;
迅捷
yourDatepicker.datePickerMode = UIDatePickerMode.Date
Swift3
yourDatepicker.datePickerMode = .date
其他模式是
- UIDatePickerModeTime,
- UIDatePickerModeDate,
- UIDatePickerModeDateAndTime,
- UIDatePickerModeCountDownTimer
选择 2
上述方法效果不佳,请查看此链接
the above method not working well, then check this link
这篇关于如何在 iOS 中使用 DatePicker 只接受月份和年份的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文