如何以编程方式创建此工具栏 [英] How to create this toolbar programmatically
本文介绍了如何以编程方式创建此工具栏的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我真的很难以编程方式创建 UIToolBar
(没有xib文件)。这就是我想要创造的。
I am really having a hard time creating a UIToolBar
programmatically(no xib file). This is what I would like to create.
但到现在为止,我觉得我没有以正确的方式接近它。我尝试过添加一个barbuttonitem,但我不能创建效果,如png所示。我应该怎么做呢。需要帮助。
But till now, I feel I have not approached it in the right way. I have tried adding a barbuttonitem to it, but I cant create the effect as shown in the png. How should I go about it. Help needed.
编辑:我添加了更大的图像
I have added a bigger image
推荐答案
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];
这篇关于如何以编程方式创建此工具栏的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文