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

use*_*514 10 uitoolbar separator ios

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

示例图像显示在以下链接中

在此输入图像描述

小智 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 = @"";
Run Code Online (Sandbox Code Playgroud)


dea*_*rne 6

我可以想到两种方式:

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

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