【发布时间】:2012-11-24 12:16:44
【问题描述】:
我正在为 iOS 开发一个通用应用程序,因此我必须将标签设置为UIToolBar 的中心。请帮我做这件事。
我已经实现的代码
UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 250, 40)];
label.backgroundColor = [UIColor clearColor];
UIBarButtonItem *item = [[UIBarButtonItem alloc] initWithCustomView:label];
NSDateFormatter *format = [[NSDateFormatter alloc] init];
[format setDateFormat:@"dd-MM-yyyy hh:mm a"];
NSDate *now = [[NSDate alloc] init];
NSString *dateString = [format stringFromDate:now];
label.text = dateString;
【问题讨论】:
标签: iphone objective-c uitoolbar