objective-c - 在 UIToolbar 之间添加间距

标签 objective-c iphone ipad uibarbuttonitem toolbaritems

我有一个如下所示的工具栏:

enter image description here

问题是它有点困惑,因此我想给它添加一些间距。我尝试这样做:

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

self.toolbar_array = 
 [[NSMutableArray alloc] initWithObjects:self.mention, 
                                         spacer, 
                                         self.picture, 
                                         spacer, 
                                         share, 
                                         spacer, 
                                         self.message, nil];

但它仍然给我同样的东西。如何在这些 UIBarButtonItems 之间添加 10px?

最佳答案

UIBarButtonItem *fixedSpace = 
  [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFixedSpace 
                                                target:nil 
                                                action:nil];
fixedSpace.width = 10;

关于objective-c - 在 UIToolbar 之间添加间距,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6798573/

相关文章:

iphone - iOS - plist 文件、nsuserdefaults 或文本数据文件

iOS - Dilemna - 如何从自定义单元格中分离出来

iphone - 具有多个 objectKeys 的 NSMutableArray 中的 NSDictionary 上的 sortUsingComparator

iphone - iOS 应用程序因查询电子邮件按钮而被拒绝

ipad - iPad 上的 Google 电子表格(带有 App 脚本)

ios - iOS 设备 (iPhone/iPad) 上的 CSS3 转换 : applying opacity transition the DOM object flashy

ios - 为什么内部类出现在 ProductName-Swift.h 中?我可以手动更改此文件吗?

iphone - 在搜索方法迭代完成后重新加载/显示 UISearchDisplayController 的 searchResultsTableView

ios - 如何让 iPhone 上的返回键让键盘消失?

ios - ld : library not found for -lCocoaLumberjack