Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
712 views
in Technique[技术] by (71.8m points)

iphone - Set background color of the deletion control of a UITableViewCell

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.

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.

How do I accomplish this?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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.

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...