Sunday, January 12, 2014

iOS 7 has added a background colour to your table cell


In iOS 7 we noticed a white background for the UITableView we were using. Whereas on iOS 6 the same code gave us a transparent background, thus enabling the background image to be visible as required by the App's owner.
This was a change done in iOS 7, so if you want to support it, do a version check and something similar to the following:  

//  (iOS 6 cell is transparent by default not on iOS 7).

      //do a version check, if it is iOS 7 run the below code
        cell.backgroundColor = [UIColor clearColor];
    


You can use a callback method such as the one below to add your code if you are not sure where to place it:

- (UITableViewCell *) tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath 
{
     if([AppDelegate iSIOS7OrAbove]){  // iSIOS7OrAbove is not a method that comes out of the box. write the logic you want in a custom method to do the check.
        cell.backgroundColor = [UIColor clearColor];
    }

}


Hope this helped someone :)

No comments:

Post a Comment