19.UIDatePicker日期选择器

// 日期选择器

    _picker = [[UIDatePicker alloc] init];

    [_picker addTarget:self action:@selector(pickerDidMove:)forControlEvents:UIControlEventValueChanged];

    [_picker setLocale:[NSLocale systemLocale]];//设置日期选择器语言--中文,英文

NSLocale *usLocale = [[NSLocale alloc] initWithLocaleIdentifier:@"en_US_POSIX"]


到底使用en_US_POSIX还是en_US, Apple在SDK文档中给出了答案.

In most cases the best locale to choose is “en_US_POSIX”

因为

“en_US_POSIX” is also invariant in time (if the US, at some point in the future, changes the way it formats dates, “en_US” will change to reflect the new behaviour, but “en_US_POSIX” will not), and between machines (“en_US_POSIX” works the same on iPhone OS as it does on Mac OS X, and as it it does on other platforms).


[[NSLocale alloc] initWithLocaleIdentifier:@"zh_Hans"]

    _picker.maximumDate = [NSDate date];//最大日期是今天

    [_picker setDatePickerMode:datePickerMode];//设置模式为日期,时间  或者日期加时间

    [_backView addSubview:_picker];

自定义日期选择器见Life365 --AddMuteTimeViewController.m

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值