UIDatePicker 中文显示和日期格式转换

来源:互联网 发布:广联达免费预算软件 编辑:程序博客网 时间:2024/05/17 07:36

1、中文显示:

NSLocale *locale = [[NSLocale alloc] initWithLocaleIdentifier:@"zh_CN"];//设置为中datePicker.locale = locale;

2、格式转换:

NSDate *selected = [datePicker date];NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];[dateFormatter setDateFormat:@"yyyy-MM-dd HH:mm"];NSString *destDateString = [dateFormatter stringFromDate:selected];

另:UIDatePicker不能设置高度,但是可以获取

NSInteger pickerHeight = datePicker.bounds.size.height;

0 0
原创粉丝点击