iOS10的UIBarButtonItem上的UIEdgeInsets导致图像压缩

问题描述 投票:0回答:1

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

enter image description here

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

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,按钮看起来像这样:

enter image description here

为什么会这样?我该怎么办才能修复它?

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

ios swift uibarbuttonitem
1个回答
-1
投票

我认为你只使用了正确的插图。

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

© www.soinside.com 2019 - 2024. All rights reserved.