设置UITableViewCell的删除控件的背景颜色 [英] Set background color of the deletion control of a UITableViewCell

查看:120
本文介绍了设置UITableViewCell的删除控件的背景颜色的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在iPhone / iPad应用程序中,我使用UITableView显示可以编辑的项目列表。我可以成功地在表视图中交替行的背景颜色。但是,当我打开编辑模式(即显示删除控件)时,每个单元格似乎都向右移动,删除控件从左侧滑入。

In an iPhone/iPad app, I'm using a UITableView to display a list of items that can be edited. I can successfully alternate the background color of the rows in my table view. However, when I turn on "editing mode" (i.e., display the deletion control), each cell appears to be shifted to the right, and the deletion control slides in from the left.

我的问题是删除控件具有白色背景颜色。我希望删除控件的背景颜色与我的UITableViewCell的背景颜色相匹配。

My problem is that the deletion control has a white background color. I'd like the background color of the deletion control to match the background color of my UITableViewCell.

我如何做到这一点?

推荐答案

一个答案是,在getCellContentView函数中,您创建框架/标签并将其添加为子视图,添加一个更宽的附加标签并以负X值。然后,这可以着色。由于它是在删除控件的下方绘制的,因此显示颜色。

One answer is to, in the getCellContentView function, where you create frames/labels and add them as subviews, add an additional label that is much wider and starts with a negative X value. Then, this can be colored. Since it's drawn "underneath" the deletion control, the color shows through.

诀窍是要理解删除控件在任何地方都不是白色。删除控件本身的背景颜色已经清除,因此您必须在下面放置一些东西。负x值就可以了。

The trick is to understanding that the deletion control isn't drawing "white" anywhere. The deletion control itself's background color is already clear, so you have to fit something underneath. Negative "x" value does the trick.

这篇关于设置UITableViewCell的删除控件的背景颜色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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