iOS 4.x Background Color Quirk

Today’s iOS quirk is again related UITableViews. This time, it’s the background color.

The Problem

I’m basically creating a form in a UITableView, and there are several button-type elements like segmented controls (actually they’re fake segmented controls due to customization needs) and a big search button. As a result, I want the UITableViewCells to be transparent so the table view formatting isn’t displayed. However, in iOS 4.x, all the obvious stuff that worked in iOS 5.x+ didn’t exactly work. I ended up with black corners around my buttons, as seen in the screenshot below.

iOS 4.x Broken Clear Color on Cell

The Solution

Very simple. Apparently, iOS 4.x doesn’t care what color you set the background of the UITableView to in Interface Builder (at least, not when it’s clear). You have to set the background color to clear in the code.

    [super viewDidLoad];
    self.myTableView.backgroundColor = [UIColor clearColor];

This results in the following:

iOS 4.x Fixed Clear Color on Cell

iOS 4.x Background Color Quirk
Tagged on:                     

Leave a Reply