如何在TableView中获取填充? [英] How to get a padding inside TableView?

查看:143
本文介绍了如何在TableView中获取填充?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个透明的
背景的tableView我想有一个padding
我尝试使用 contentInsets
contentSize contentOffset

CGFloat padding = 10.0f;
CGSize size = self.tableView.bounds.size;
size.width -= (padding*2);
size.height -= (padding*2);
self.tableView.contentSize = size;
self.tableView.contentInset = UIEdgeInsetsMake(padding, padding, padding, padding);
self.tableView.contentOffset = CGPointMake(-padding, -padding);

这不行。
我得到的填充,但细胞
调整大小或重新定位。

That doesn't work. I get the padding, but neither are the cells resized nor respositioned.

我知道,我可以嵌套TableView在另一个View,
,但应该有另一个解决方案。

I know, I could nest the TableView inside another View, but there should be another solution.

编辑:

我其实有一个误解'contentSize'的含义。
它不是视口的大小,而是实际大小,你命名它,内容。
所以我可能会有..

I actually had a misconception as to the meaning of 'contentSize'. It's not the viewport's size but the actual size of, you name it, the content. So I probably will have to..


  1. 尽可能调整单个单元格的大小(可能与TableView的布局过程冲突) / li>
  2. 向上述TableView应用内容偏移


推荐答案

p>对于宽度,你将不得不混乱每个单元格框架。对于顶部和底部插入,使用setContentInset:

For width, you are going to have to mess with each cells frame. as for top and bottom inset, use setContentInset:

这篇关于如何在TableView中获取填充?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆