我有一个工具栏,代码如下; 我想添加一张名为“toolsIcon.png”的图片,以“工具”显示。
以下是我的代码:
//BottomBar
UIToolbar *toolbar = [[UIToolbar alloc] init];
toolbar.frame = CGRectMake(0, self.view.frame.size.height - 44, self.view.frame.size.width, 44);
[self.view addSubview:toolbar];
[toolbar release];
//TOOLBAR ITEMS
//button 1
UIBarButtonItem *tools = [[UIBarButtonItem alloc] initWithTitle:@"Tools" style:UIBarButtonItemStyleBordered target:self action:@selector(createToolView)];
[tools setTag:0];
//add the buttons to the toolbar
NSArray *buttons = [NSArray arrayWithObjects: tools,nil];
[toolbar setItems: buttons animated:YES];
//memory management for buttons - don't waste!
[tools release];