Whenever a UITableViewCell is selected or highlighted, it automatically sets the backgroundColor
s of all its subviews to transparent.
This makes sense for many views, such as UILabels to allow the selectedBackgroundView
to show through inbetween the individual letters.
However with custom views, there are many cases where the backgroundColor should be maintained on selection of highlighting of the cell.
KeepBackgroundCell provides a way to turn of this transparency "feature" on individual UITableViewCells.
import KeepBackgroundCell
let cell = < Initialize UITableViewCell >
cell.keepSubviewBackground = true
#import <KeepBackgroundCell/KeepBackgroundCell.h>
UITableViewCell* cell = < Initialize UITableViewCell >
cell.keepSubviewBackground = YES;
KeepBackgroundCell is available through CocoaPods. To install it, simply add the following line to your Podfile:
pod "KeepBackgroundCell"
Tim Bodeit, [email protected]
KeepBackgroundCell was inspired by this answer by Yatheesha B L on stackoverflow.
KeepBackgroundCell is available under the MIT license. See the LICENSE file for more info.