How to accept only Month and Year using DatePicker in iOS

后端 未结 3 1729
攒了一身酷
攒了一身酷 2021-01-12 09:40

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 usi

3条回答
  •  刺人心
    刺人心 (楼主)
    2021-01-12 09:56

    Choice-1

    Objective-C

    yourDatepicker.datePickerMode = UIDatePickerModeDate;
    

    Swift

     yourDatepicker.datePickerMode = UIDatePickerMode.Date
    

    Swift3

    yourDatepicker.datePickerMode = .date
    

    the another modes are

    • UIDatePickerModeTime,
    • UIDatePickerModeDate,
    • UIDatePickerModeDateAndTime,
    • UIDatePickerModeCountDownTimer

    Choice-2

    the above method not working well, then check this link

提交回复
热议问题