TableViewCell滑动操作中的图像 [英] Image in TableViewCell swipe action

查看:78
本文介绍了TableViewCell滑动操作中的图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个滑动动作可以完成"待办事项列表应用程序中的任务.这是我设置的图像:

I have a swipe action to 'complete' a task in my to-do list app. This is the image I have set:

但是,当滑动单元格时,图像如下所示:

However when the cell is swiped, the image looks like this:

有没有一种方法可以使背景透明/白色,并且图像具有与上图一样的绿色圆圈?

Is there a way to make the background transparent/white and the image to have the green circle like the image above?

如果没有,是否有办法使绿色背景包裹"到细胞的紫色,从而没有空格? 谢谢!

If there is not, is there a way to make the green background 'wrap' to the purple of the cell so there is no whitespace? Thanks!

推荐答案

在第二个图像中,绿色是UIContextualAction的backgroundColor,白色是tintColor.

In the second image, the green is the UIContextualAction's backgroundColor and the white is the tintColor.

将图像视为模板图像-即忽略其颜色,而是在图像透明的情况下将其绘制为透明,而在图像不透明的情况下使用tintColor绘制为不透明.

The image is treated as a template image — that is, its colors are ignored, and instead it is drawn transparent where your image is transparent, and drawn opaque with the tintColor where your image is opaque.

因此,基本上,您需要反转设置:将背景色设置为白色,然后将色调颜色更改为图像中显示的深绿色.设置颜色的颜色并不容易,但是您可以按照建议didFinishLaunching中进行设置>此处(尽管这可能会带来其他有害的副作用):

So, basically you would need to reverse your settings: set the background color to white and change the tint color to the darker green shown in your image. Setting the tint color is not easy, but you could do it, for example, in your app delegate didFinishLaunching using the appearance proxy, as suggested here (though this may have other unwanted side effects):

UIImageView.appearance(
    whenContainedInInstancesOf: [UITableView.self])
        .tintColor = // whatever that green is

这篇关于TableViewCell滑动操作中的图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆