【问题标题】:iOS: Increase spacing to UIBarButtonItemiOS:增加 UIBarButtonItem 的间距
【发布时间】:2015-11-24 05:35:57
【问题描述】:

我做了一个自定义的UINavigationBar 看起来像这样:[

现在我想增加左右栏按钮之间的间距。我尝试以这种方式使用UIEdgeInsets 这样做:

self.navigationItem.leftBarButtonItem?.imageInsets = UIEdgeInsetsMake(0, 20, 0, 0)

然后它就被尖叫:

【问题讨论】:

    标签: ios swift insets uiedgeinsets


    【解决方案1】:

    您可以在按钮前添加额外的间距项:

        let button = UIBarButtonItem(title: "<", style: .plain, target: self, action: "someSelector")
        let spacing = UIBarButtonItem(barButtonSystemItem: .fixedSpace, target: nil, action: nil)
        spacing.width = 20;
        navigationItem.leftBarButtonItems = [spacing, button]
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2018-12-21
      • 1970-01-01
      • 2014-12-24
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多