UIToolBar 添加任意的视图 方法

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];

你可能感兴趣的:(UIToolBar 添加任意的视图 方法)