If you need different seperator colors for different lines or you want the separator to remain visible when the line is highlighted by a tap, try the following:
self.tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
This assumes that the background color of your cell is transparent.
The above solution came out of some extensive experiments. Here are some notes on my findings that I’m sure will help people:
In the normal "unselected" state
- ContentView (which in your XIB, unless you encoded it otherwise) is usually drawn
- SelectedBackgroundView HIDDEN
- The background view is visible (provided that your content view is transparent, you see a backgroundView or (if you have not defined a backgroundView, you will see the background color of the UITableView itself)
A cell is selected, any animation immediately happens with-OUT:
- All views / subheadings in the contentView have their own backgroundColor, cleared (or set to transparency), color change for label text, etc. with their chosen color.
- The selected BackgroundView becomes visible (this view is always the full size of the cell (the user frame is ignored if you need to use it), also note that the backgroundColor of the sub-windows is not displayed for any reason, maybe re set transparently like the contentView). If you have not defined selectedBackgroundView, then Cocoa will create / paste a blue (or gray) gradient background and display it for you)
- The background screen does not change
When the cell is canceled, the animation to remove the highlight starts:
- The selected alphaBackgroundView property animates from 1.0 (fully opaque) to 0.0 (fully transparent).
- The background screen has not changed again (so the animation looks like a crossfade between the selected BackgroundView and backgroundView)
- Only after the animation is completed, the ContentView will be redrawn in the “not selected” state, and its subview backgroundColor will become visible again (this can lead to your animation looking awful, so it is advisable that you do not use the UIView. BackgroundColor in your contentView)
Oliver Pearmain Mar 11 '13 at 14:09 2013-03-11 14:09
source share