iOS 关于UIDatePicker、UIPickerView常见使用方法

本文介绍了如何在iOS应用中使用UIDatePicker和UIPickerView。首先,通过设置UIDatePicker的模式、地区、时区、日期等属性,并添加事件监听来实现时间选择功能。接着,展示了UIPickerView的创建过程,包括设置显示选项、数据源和代理方法,以及自定义列数、行数和显示内容的方法。
摘要由CSDN通过智能技术生成

Step---1:

 UIDatePicker*_datePiceker = [[UIDatePickeralloc] init];

    _datePiceker.frame= CGRectMake(10, 10, 300, 100);

 /*设置日期选择控件的样式

     UIDatePickerModeTime 时间模式

     UIDatePickerModeDate 日期模式

     UIDatePickerModeDateAndTime 日期时间模式

     UIDatePickerModeCountDownTimer 倒计时模式

     */

    _datePiceker.datePickerMode= UIDatePickerModeTime;

 //设置日期选择控件的地区

 NSLocale*_local =  [[NSLocalealloc]initWithLocaleIdentifier:@"zh_Hans_CN"];

    _datePiceker.locale= _local;

 //默认为当天

 NSCalendar*_calendar = [NSCalendarcurrentCalendar];

    _datePiceker.calendar= _calendar;

 //设置时区。

 NSTimeZone*_timeZone = [NSTimeZonedefaultTimeZone];

    _datePiceker.timeZone= _timeZone;

 //日期

 NSDate*_date = [NSDatedate];

    _datePiceker.date= _date;

 //倒计时 先指定模式 UIDatePickerModeCo

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值