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

前端 未结 9 2348
暗喜
暗喜 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:31

    More accurate left margin for the 'stretchy' zone instead of the 'apx. 6% calc.'

    Side note: the iPad implements additional section top and bottom padding in addition to the left margin padding, it's 10.0f below 400.0f table width and 31.0f otherwise.

    -(CGFloat)leftMarginForTableView:(UITableView*)tableView
    {
        if (tableView.style != UITableViewStyleGrouped) return 0;
        CGFloat widthTable = tableView.bounds.size.width;
        if (isPhone)              return (10.0f);
        if (widthTable <= 400.0f) return (10.0f);
        if (widthTable <= 546.0f) return (31.0f);
        if (widthTable >= 720.0f) return (45.0f);
        return (31.0f + ceilf((widthTable - 547.0f)/13.0f));
    }
    

提交回复
热议问题