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

时间:2012-02-07 17:05:13

标签: ios uitoolbar separator

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

示例图片显示在以下链接

enter image description here

5 个答案:

答案 0 :(得分:15)

我使用自定义视图按钮,背景为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 = @"";

答案 1 :(得分:6)

我可以想到两种方式:

(a)您可以使用非常轻薄的工具栏按钮禁用用户交互。

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

答案 2 :(得分:0)

我建议最简单的解决方法是将分隔符图像覆盖在工具栏的顶部。使用UIToolBar没有固定的方法。

答案 3 :(得分:0)

如果你想要一个干净,简单的布局,我宁愿选择一个带有这个分隔符的超薄图像。然后,您可以在普通按钮,分隔符图像按钮(禁用用户交互)和下一个按钮之间添加固定距离。

答案 4 :(得分:0)

您也可以制作工具栏按钮并设置Title = |

相关问题