Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/94.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios UIToolbar中工具栏项之间的分隔符_Ios_Uitoolbar_Separator - Fatal编程技术网

Ios UIToolbar中工具栏项之间的分隔符

Ios UIToolbar中工具栏项之间的分隔符,ios,uitoolbar,separator,Ios,Uitoolbar,Separator,如何在UIToolbar中的按钮之间添加分隔符 下面的链接中显示了示例图像 我可以想出两种方法: (a) 您可以在禁用用户交互的情况下使它们成为非常薄的工具栏按钮 (b) 您的另一个选择是实现您自己的工具栏。我会先试试;) 如果你想要一个干净、简单的布局,我更喜欢一个带有分隔符的非常薄的图像。然后,您可以在“普通”按钮、“分隔图像”按钮(禁用用户交互)和“下一步”按钮之间添加固定距离。我使用了一个自定义视图按钮,背景为1像素宽: UILabel *label = [[UILabel alloc]

如何在UIToolbar中的按钮之间添加分隔符

下面的链接中显示了示例图像


我可以想出两种方法:

(a) 您可以在禁用用户交互的情况下使它们成为非常薄的工具栏按钮


(b) 您的另一个选择是实现您自己的工具栏。我会先试试;)

如果你想要一个干净、简单的布局,我更喜欢一个带有分隔符的非常薄的图像。然后,您可以在“普通”按钮、“分隔图像”按钮(禁用用户交互)和“下一步”按钮之间添加固定距离。

我使用了一个自定义视图按钮,背景为1像素宽:

UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 1, 44)];
label.backgroundColor = [UIColor whiteColor];

UIBarButtonItem *divider = [[UIBarButtonItem alloc] initWithCustomView:label];
// Add button to array of toolbar items
[items addObject:divider];
// Or set items directly:
//toolbar.items = [NSArray arrayWithObject:divider];
label.text = @"";

您还可以制作一个工具栏按钮并设置标题=|

过去我必须这样做,最简单的方法,至少在iOS 5下,是使用方法(a)。使用新的自定义外观api,设置背景图像并将按钮宽度设置为1px,效果非常令人信服。然后,您可以像往常一样使用灵活的垫片,使所有内容保持对齐。