有没有办法增加间距UITableViewCell?
我创建了一个表,每个单元格只包含一个图像.图像被分配给单元格,如下所示:
cell.imageView.image = [myImages objectAtIndex:indexPath.row];
Run Code Online (Sandbox Code Playgroud)
但这会使图像放大并适合整个单元格,图像之间没有间距.
或者以这种方式说,图像的高度例如是50,并且我想在图像之间添加20个间隔.有没有办法实现这个目标?
我有一个UITableView,其中包含x个单元格.但是,我希望每个单元格之间的距离为20 px.我的tableview只包含一个部分.
我在谷歌搜索并搜索论坛,但我找不到任何适用于我的目的.
是否可以设置单元格的内容偏移量或单元格内的imageview?
有人可以帮帮我吗?
我需要添加填充,以便在swift 2.1中每个部分的每个单元格之间留出空间
但我设法做的就是为我不想要的部分添加标题.
如何在动态表格单元格之间添加空格?
以下是添加标头的代码:
// Set the spacing between sections
override func tableView(tableView: UITableView, heightForHeaderInSection section: Int) -> CGFloat {
return 10
}
override func tableView(tableView: UITableView, viewForHeaderInSection section: Int) -> UIView? {
let header = UIView()
header.backgroundColor = UIColor.clearColor()
return header
}
Run Code Online (Sandbox Code Playgroud)
这是创建表视图代码:
override func numberOfSectionsInTableView(tableView: UITableView) -> Int {
return 1
}
override func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return self.tableData.count
}
override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
//Table view …Run Code Online (Sandbox Code Playgroud) 我正在尝试使用自定义分隔符创建一个tableview.我制作了一个包含内容的自定义Cell,另一个只包含带分隔符的UIImageView.问题在于如何访问内容.我不能使用indexPath.row
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
CustomCell *cell = (CustomCell *) [tableView dequeueReusableCellWithIdentifier: @"CustomCell"];
if(cell == nil)
{
cell = [[[NSBundle mainBundle] loadNibNamed:@"CustomCell" owner:self options:nil] objectAtIndex:0];
}
SeparatorCell *cellSeparator = (SeparatorCell *) [tableView dequeueReusableCellWithIdentifier: @"SeparatorCell"];
if(cellSeparator == nil)
{
cellSeparator = [[[NSBundle mainBundle] loadNibNamed:@"SeparatorCell" owner:self options:nil] objectAtIndex:0];
}
if(indexPath.row % 2)
{
UIFont * myCustomFont = [UIFont fontWithName:@"Arial Black" size:16];
[cell.titulo setFont:myCustomFont];
cell.titulo.textColor = [UIColor colorWithRed:103/255.0f green:169/255.0f blue:0/255.0f alpha:1];
cell.titulo.text = [Title objectAtIndex:myRow];
cell.subtitle.text = [Subtitle objectAtIndex:myRow];
cell.tag …Run Code Online (Sandbox Code Playgroud) objective-c ×3
ios ×2
uitableview ×2
cellpadding ×1
cocoa ×1
cocoa-touch ×1
custom-cell ×1
iphone ×1
spacing ×1
swift ×1
xcode ×1