iOS 13 - UIBarButtonItem大小太小

4
我正在将我的应用程序更新到iOS 13,但我的UIBarButtonItems变小了。
iOS 13截图: enter image description here iOS 12截图: enter image description here 看一下暂停图标。它更小了。
我的代码:
[[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemPlay target:self action:@selector(botaoPressionado:)];                                                      

有什么办法可以修复这个问题吗?

1
你能展示一下如何将图形添加到UIBarButtonItem的代码吗? - Michael Dautermann
@MichaelDautermann已添加! - Erick Filho
这感觉像是一个潜在的自动布局/约束问题。但无论如何,那一行并没有对我太有帮助,我很想看到更多的代码(例如,你如何分配正常大小的右侧栏按钮项,以及如何设置滑块两侧的两个按钮)。 - Michael Dautermann
我认为这是本地行为,所以我们无法更改。您可能需要在iOS 13中使用图像。 UIBarButtonItem.init(image: UIImage(named: "play.png"), style: .plain, target: self, action: nil) - Mitesh
@MichaelDautermann 这是一个按钮数组。音量条的大小取决于设备的宽度,具有固定的尺寸。 - Erick Filho
显示剩余5条评论
2个回答

3

iOS 13中的本地图片已经更改。 UIBarButtonSystemItemPlay 图片已更改。同样,您使用的第二个 UIBarButtonSystemItemAction 图像也已更改。

Xcode 10 - iOS 12:

enter image description here

Xcode 11 - iOS 13:

enter image description here

如果您希望在两个iOS版本中保持一致,请添加自定义图像到工具栏按钮中。

编辑

更改工具栏按钮项的色调颜色:

barButtonItem.tintColor = .black

如果您想使用自定义图像,则需要设置“bar button system item property custom”。具体操作如下:
barButtonItem.image = UIImage(named: "imageName")?.withRenderingMode(.alwaysOriginal)

谢谢回复。是否可以通过编程方式更改图像颜色?设置色调或其他什么东西。因为根据颜色,我的按钮会改变。 - Erick Filho
我之所以问这个问题,是因为我之前尝试过,但图像始终保持原始颜色。 - Erick Filho
你可以通过设置UIBarButtonItem的tintColor来改变颜色。 - Mitesh

0
在iOS 13中,新的SFSymbols可以根据空间自动调整图标大小。
在这种情况下,音量条具有固定大小,它太大了,导致播放/暂停按钮被挤压。
减小音量条宽度进行修复,现在看起来是这样的:

enter image description here


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接