9 objective-c uitoolbar ios theos
我有一个工具栏,下面是代码; 我想添加一个显示"Tools"的图像,名为"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];
Run Code Online (Sandbox Code Playgroud)
您可以使用图像创建UIBarButtonItem并添加它
UIBarButtonItem* item = [[UIBarButtonItem alloc] initWithImage: yourImage style: UIBarButtonItemStyleBordered target: nil action: nil];
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
848 次 |
| 最近记录: |