我想在UIToolBar的中心位置放一个按钮。在下面的代码中我必须做什么改变?是否可以在iPhone上的UIToolBar中放置一个按钮?
CGRect toolbarFrame = CGRectMake(0, 0, self.view.frame.size.width, 44);
UIToolbar *mytoolbar = [[UIToolbar alloc] initWithFrame:toolbarFrame];
mytoolbar.autoresizingMask = UIViewAutoresizingFlexibleWidth;
mytoolbar.tintColor = [UIColor blackColor];
UIBarButtonItem *button = [[UIBarButtonItem alloc] initWithTitle:@"button 1"
style:UIBarButtonItemStylePlain target:self action:nil];
NSMutableArray *tools = [[NSMutableArray alloc] initWithObjects:button,nil];
[mytoolbar setItems:tools];
[self.view addSubview:mytoolbar];
谢谢!这帮助了我。 – 2010-12-13 01:19:09