I need to change the selected cell background colour for all the cells in my app. As I know there is a way to use UIAppearance
protocol for this purposes. Is it
As null's answer is not for selected cell backgrounds and Armands L.'s answer did not work consistently for me (selecting cells by 'user-tap' did work, but programmatical cell selection showed strange results (like sometimes the selected background was not visible, or did not fill the cell's height properly...).
I found a custom solution that worked:
UITableViewCell
self.selectedBackgroundView
in init
and UIColor
property with UI_APPEARANCE_SELECTOR
for custom selected background color.h
file:
@property (nonatomic) UIColor* selectedCellBackgroundColor UI_APPEARANCE_SELECTOR;
.m
file:
in init
method(s):
self.selectedBackgroundView = [[UIView alloc] init];
and last but not least the setter function for the color:
- (void) setSelectedCellBackgroundColor:(UIColor*) color {
_selectedCellBackgroundColor = color;
self.selectedBackgroundView.backgroundColor = color;
}