【问题标题】:UIEdgeInsets on UIBarButtonItem for iOS10 causes images to squashiOS10 的 UIBarButtonItem 上的 UIEdgeInsets 导致图像挤压
【发布时间】:2019-02-19 10:47:12
【问题描述】:

嘿,我有一个这样的导航栏:

要微调UIBarButtonItems 在右侧的位置,我需要使用图片插图。我有一个方便的初始化按钮的初始化方法:

convenience init(type: ButtonType, target: Any?, selector: Selector) {
  let image: UIImage = type.image.withRenderingMode(.alwaysTemplate)
  self.init(image: image, style: .plain, target: target, action: selector)
  imageInsets = type.imageInsets
}

这很好,但对于 iOS10,按钮看起来像这样:

为什么会这样?我能做些什么来解决它?

任何建议都会很棒,谢谢!

【问题讨论】:

    标签: ios swift uibarbuttonitem


    【解决方案1】:

    我认为你只使用了右插图。

    您可以尝试:右插图 = 10,左插图 = -10。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2015-08-19
      • 1970-01-01
      • 2020-10-15
      • 2012-11-16
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多