UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 100, 44)];
label.font=[UIFont systemFontOfSize:16];
label.backgroundColor = [UIColor whiteColor];
label.textAlignment=UITextAlignmentCenter;
label.text = @"testlabel";
UIBarButtonItem *buttonItem = [[UIBarButtonItem alloc]initWithCustomView:label];
NSArray *itemArray = [NSArray arrayWithObjects:buttonItem, nil];
[self.navigationController.toolbar setItems:itemArray animated:YES];
转载于:https://www.cnblogs.com/skyry/archive/2013/04/16/5114608.html