0

I have UICOllectionViewCell and I was using setSelectedMethod to determine which background color I have to show. It is working fine in iOS 14 but in iOS 15 it's not working. Here is the code

- (void)setSelected:(BOOL)selected {
    if (selected) {
        self.layer.borderColor = [UIColor colorWithWhite:1 alpha:0.5].CGColor;
        self.layer.borderWidth = 2.0f;
        self.textLabel.textColor = [UIColor whiteColor];
        self.backgroundColor = kAppDefaultThemeColor;
    }
    else{
        self.layer.borderColor = kAppDefaultThemeColor.CGColor;
        self.layer.borderWidth = 2.0f;
        self.textLabel.textColor = [UIColor blackColor];
        self.backgroundColor = [UIColor colorWithWhite:1 alpha:0.5];
    }
}
Rahul Vyas
  • 28,260
  • 49
  • 182
  • 256
  • You should not be setting the background color of a cell directly. It is a background configuration feature (https://developer.apple.com/documentation/uikit/uibackgroundconfiguration). Also you should not be referring to `textLabel`. Text features are a list configuration feature (https://developer.apple.com/documentation/uikit/uilistcontentconfiguration). – matt Oct 08 '21 at 13:50
  • @matt thanks buddy. Is there any possibility to use apperance API for customizing UIcollectionViewCells and UITableViewCells? I would like to have something like different background color for different cells and for different states (Highlighted|Selected) etc. – Rahul Vyas Oct 13 '21 at 10:14

0 Answers0