很难说出这里问的是什么。这个问题是模棱两可的、模糊的、不完整的、过于宽泛的或修辞的,无法以目前的形式得到合理的回答。如需帮助澄清这个问题以便重新打开它,visit the help center .
9年前关闭。
我真的很难创建 UIToolBar
以编程方式(没有 xib 文件)。这就是我想要创造的。
但直到现在,我觉得我还没有以正确的方式接近它。我尝试向其添加 barbuttonitem,但无法创建 png 中显示的效果。我该怎么办。需要帮助。
编辑:我添加了更大的图像
最佳答案
UIBarButtonItem *spaceItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace target:nil action:nil];
[self.navigationController.toolbar setBarStyle:UIBarStyleBlackOpaque];
UIBarButtonItem *customItem = [[UIBarButtonItem alloc] initWithTitle:@"toolbar title" style:UIBarButtonItemStylePlain target:self action:@selector(onToolbarTapped:)];
NSArray *toolbarItems = [NSArray arrayWithObjects:spaceItem, customItem, spaceItem, nil];
[self setToolbarItems:toolbarItems animated:NO];
关于iphone - 如何以编程方式创建此工具栏,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10500708/