Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
714 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 Reply

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...