简体   繁体   English

UITableViewRowAction 的图标显示在 iOS 13 上,但不在 iOS 12 上

[英]Icon for UITableViewRowAction is shown on iOS 13, but not on iOS 12

Ok, I've encountered a strange behaviour (bug) by UITableViewRowAction .好的,我遇到了UITableViewRowAction的奇怪行为(错误)。 I'm trying to add an icon to a swipe left action.我正在尝试向左滑动操作添加图标。 Bellow is my code for setting an icon inside the table view delegate's tableView(_:trailingSwipeActionsConfigurationForRowAt:) method (action is an instance of UIContextualAction ): Bellow 是我在表视图委托的tableView(_:trailingSwipeActionsConfigurationForRowAt:)方法中设置图标的代码(action 是UIContextualAction的一个实例):

action.image = UIGraphicsImageRenderer(size: Constants.swipeActionImageSize)
        .image(actions: { _ in
            Constants.messageReplyIcon.draw(in: CGRect(origin: .zero,
                                                       size: Constants.swipeActionImageSize))
    })

I'm using this solution since need to resize the image a little bit.我正在使用此解决方案,因为需要稍微调整图像大小。 This works fine on iOS 13 but on iOS 12 (actually, running on iOS 12.2), it renders the image as a white circle.这在 iOS 13 上运行良好,但在 iOS 12 上(实际上,在 iOS 12.2 上运行),它将图像呈现为白色圆圈。 Bellow, you can see screenshots of the icon on iOS 13 simulator and on iOS 12.2 simulator one after another.下面,你可以看到iOS 13模拟器和iOS 12.2模拟器上的图标截图一个接一个。

iOS 13 iOS 13

在此处输入图像描述

iOS 12.2 iOS 12.2

在此处输入图像描述

Note that this happens even when I simply set the image, without doing all that fancy stuff for resizing.请注意,即使我只是简单地设置图像,而没有做所有花哨的调整大小的事情,也会发生这种情况。

However, when I look at the image in UI Debugger while sill on iOS 12, I see the following:但是,当我在 iOS 12 上查看 UI 调试器中的图像时,我看到以下内容:

在此处输入图像描述

I suspect, the UIContextualAction applies some tint color to the icon on iOS 12, but can't figure out why, and because of that, can't find a solution.我怀疑, UIContextualAction对 iOS 12 上的图标应用了一些淡色,但不知道为什么,因此找不到解决方案。

Maybe, you've encountered something like this, or have ideas about the reasons?也许,你遇到过这样的事情,或者对原因有什么想法? Thanks in advance.提前致谢。

UIContextualAction on older versions of iOS converts the image to a template that will be painted white.旧版本UIContextualAction上的 UIContextualAction 将图像转换为将被涂成白色的模板。 Although the documentation doesn't say anything about it.尽管文档没有说明任何内容。

See about templates:查看模板:

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM