且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何在按钮之间创建空间?

更新时间:2023-11-21 16:31:28

您可以使用两种内置空格按钮类型之一在工具栏项之间添加空格 UIBarButtonSystemItemFixedSpace UIBarButtonSystemItemFlexibleSpace .

You can add spaces between tool bar items using either of the two built-in space button types UIBarButtonSystemItemFixedSpace and UIBarButtonSystemItemFlexibleSpace.

固定空间按钮

UIBarButtonItem *fixedSpace = [[UIBarButtonItem alloc] 
                   initWithBarButtonSystemItem:UIBarButtonSystemItemFixedSpace 
                                        target:nil 
                                        action:nil];
[fixedSpace setWidth:20];

弹性空间按钮

UIBarButtonItem *flexibleSpace = [[UIBarButtonItem alloc] 
                initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace 
                                     target:nil 
                                     action:nil];

在其他工具栏项目之间添加空格键.

Add the space bar buttons in between the other tool bar items.