How to determine margin of a grouped UITableView (or better, how to set it)

uitableview

The grouped UITableView places a margin between the edge of the view and the table cells. Annoyingly (for me) this margin is some function of the width of the view.

In my application I have two UITableViews of different widths that I am looking to align the cell edges of.

Is it possible to get this margin? Or better is it possible to set this margin?

cheers,
–Ben

Best Answer

Grouped TableView Width in Relation to Cell Margin

TBWidth (0 to 20) Left Margin = TBWidth - 10

TBWidth (20 to 400) Left Margin = 10

TBWidth (401 to 546) Left Margin = 31

TBWidth (547 to 716) Left Margin = apx 6% of tableView

TBWidth (717 to 1024) Left Margin = 45

- (float) groupedCellMarginWithTableWidth:(float)tableViewWidth
{
    float marginWidth;
    if(tableViewWidth > 20)
    {
        if(tableViewWidth < 400)
        {
            marginWidth = 10;
        }
        else
        {
            marginWidth = MAX(31, MIN(45, tableViewWidth*0.06));
        }
    }
    else
    {
        marginWidth = tableViewWidth - 10;
    }
    return marginWidth;
}