Iphone 检查与UIDatePicker一起使用的24小时模式或AM/PM模式
我有一个环绕UIDatePicker的边框,用自定义视图隐藏它周围的蓝色。。我知道在时间模式下,不可能将其设置为专门的AM/PM日期选择器或24小时日期选择器。不过,我想知道如何才能找到它当前的设置,这样我就可以围绕它调整边框,因为它们的大小都不同。这很简单,您应该检查myDateString中的AMSymbol和PMSymbol是否为“NSNotFound”:Iphone 检查与UIDatePicker一起使用的24小时模式或AM/PM模式,iphone,objective-c,uidatepicker,Iphone,Objective C,Uidatepicker,我有一个环绕UIDatePicker的边框,用自定义视图隐藏它周围的蓝色。。我知道在时间模式下,不可能将其设置为专门的AM/PM日期选择器或24小时日期选择器。不过,我想知道如何才能找到它当前的设置,这样我就可以围绕它调整边框,因为它们的大小都不同。这很简单,您应该检查myDateString中的AMSymbol和PMSymbol是否为“NSNotFound”: +(BOOL) is24h { NSDateFormatter *myFormatter = [[NSDateFormatter
+(BOOL) is24h {
NSDateFormatter *myFormatter = [[NSDateFormatter alloc] init];
[myFormatter setLocale:[NSLocale currentLocale]];
[myFormatter setDateStyle:NSDateFormatterNoStyle];
[myFormatter setTimeStyle:NSDateFormatterShortStyle];
NSString *myDateString = [myFormatter stringFromDate:[NSDate date]];
NSRange myAmRange = [myDateString rangeOfString:[myFormatter AMSymbol]];
NSRange myPmRange = [myDateString rangeOfString:[myFormatter PMSymbol]];
return (myAmRange.location == NSNotFound && myPmRange.location == NSNotFound);
}
这很简单,您应该检查myDateString中的AMSymbol和PMSymbol是否为“NSNotFound”:
+(BOOL) is24h {
NSDateFormatter *myFormatter = [[NSDateFormatter alloc] init];
[myFormatter setLocale:[NSLocale currentLocale]];
[myFormatter setDateStyle:NSDateFormatterNoStyle];
[myFormatter setTimeStyle:NSDateFormatterShortStyle];
NSString *myDateString = [myFormatter stringFromDate:[NSDate date]];
NSRange myAmRange = [myDateString rangeOfString:[myFormatter AMSymbol]];
NSRange myPmRange = [myDateString rangeOfString:[myFormatter PMSymbol]];
return (myAmRange.location == NSNotFound && myPmRange.location == NSNotFound);
}