0

我是 iPhone 的初学者,我在工具栏中设置了相同大小的所有按钮,提供任何建议和源代码

4

1 回答 1

0

您必须构建一个 NSMutableArray 并将 5 个 UIBarButtonItem 放入其中,根据需要设置它们的属性,然后在 ToolBarItems 中设置此数组,如下所示:

NSMutableArray *buttonsArray = [[NSMutableArray alloc] init];
UIBarButtonItem *myButton1=[[UIBarButtonItem alloc] style:UIBarButtonItemStylePlain target:self action:@selector(toolbarButtonPressed1:)];
[buttonsArray addObject:myButton1];
//here you set the other properties for your first button

// and then you do the same for your other buttons


[self setToolbarItems:buttonsArray animated:YES];

当然你必须先声明一个 ToolBar :)

于 2012-05-11T08:56:19.137 回答