Why do all backgrounds disappear on UITableViewCell select?

前端 未结 8 1879
南笙
南笙 2020-12-02 14:22

My current project\'s UITableViewCell behavior is baffling me. I have a fairly straightforward subclass of UITableViewCell. It adds a few extra elements to the base view (vi

8条回答
  •  独厮守ぢ
    2020-12-02 14:50

    I created a UITableViewCell category/extension that allows you to turn on and off this transparency "feature".

    You can find KeepBackgroundCell on GitHub

    Install it via CocoaPods by adding the following line to your Podfile:

    pod 'KeepBackgroundCell'
    

    Usage:

    Swift

    let cell = 
    cell.keepSubviewBackground = true  // Turn  transparency "feature" off
    cell.keepSubviewBackground = false // Leave transparency "feature" on
    

    Objective-C

    UITableViewCell* cell = 
    cell.keepSubviewBackground = YES;  // Turn  transparency "feature" off
    cell.keepSubviewBackground = NO;   // Leave transparency "feature" on
    

提交回复
热议问题