Separator between toolbar items in UIToolbar

女生的网名这么多〃 提交于 2019-12-05 01:52:42

I can think of two ways :

(a) You could make them very thin toolbar buttons with user interaction disabled.

(b) Your other choice would be to implement your own toolbar. I'd try (a) first ;)

I did it with a custom view button, with a 1 pixel wide background:

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 = @"";

If yo want a clean, simple layout I would prefer a very thin image with this separator in it. Then you can add fix distances between your normal button, the separator image button (user interaction disabled) and the next button.

You can also make a toolbar button and set the Title = |

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!