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

前端 未结 9 2411
暗喜
暗喜 2020-12-07 17:48

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.

9条回答
  •  不思量自难忘°
    2020-12-07 18:18

    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;
    }
    

提交回复
热议问题