首先,我想提前感谢您对我的帮助。
我想知道如何使用 Xcode 在标签上创建日期, 并且日期将遵循与 iphone 中相同的日期。
谢谢
最佳答案
这是一种简单的方法
NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
//uncomment to get the time only
//[formatter setDateFormat:@"hh:mm a"];
//[formatter setDateFormat:@"MMM dd, YYYY"];
[formatter setDateStyle:NSDateFormatterMediumStyle];
//get the date today
NSString *dateToday = [formatter stringFromDate:[NSDate date]];
UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 320.0f, 20.0f)];
[label setText:dateToday];
[formatter release];
//then add to a view
关于objective-c - 在 xcode 标签中创建日期,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5886807/