在标题上保留UITableView填充但在IOS7上的分隔符中没有 [英] Keep UITableView padding on header but no in separator on IOS7

查看:146
本文介绍了在标题上保留UITableView填充但在IOS7上的分隔符中没有的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在iOS7上进行转换时,分隔符左侧有15px填充。我知道我可以在xib文件中的UITableView设置中使用分隔符插入功能删除此填充,但我需要使用填充保持标题文本。怎么做?

with the transition on iOS7 the separator has 15px padding on left. I know that i can remove this padding with separator inset feature on the UITableView setting in the xib file, but i need to keep heading text with padding. How to do it?

默认:

自定义分隔符插入0:

我需要像图2那样保留分隔符,但标题为2013​​,如图1所示。

i need to keep separators like figure 2, but the header with "2013" like picture 1.

推荐答案

您可以设置分隔符它通过故事板

for Seperator you can set it via Storyboard

和标题生成这样的自定义标题

and for header make a custom header like this

- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section { 
  UIView *viewHeader = [UIView.alloc initWithFrame:CGRectMake(0, 0, tableView.frame.size.width, 28)];
  UILabel *lblTitle = [UILabel.alloc initWithFrame:CGRectMake(6, 3, 136, 21)];

  [lblTitle setFont:[UIFont fontWithName:@"HelveticaNeue" size:13]];
  [lblTitle setTextColor:[UIColor blackColor]];
  [lblTitle setTextAlignment:NSTextAlignmentLeft];
  [lblTitle setBackgroundColor:[UIColor clearColor]];
  [viewHeader addSubview:lblTitle];

  return viewHeader;
}

给它任何特定的高度。并给它任何文字。
为包含年份的部分标题创建一个数组。

give it any particular height. and give it any text. make an Array for section Headers which will contain your years.

这篇关于在标题上保留UITableView填充但在IOS7上的分隔符中没有的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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