iOS中的UITableViewCell页脚文本

我想要像下面的照片一样做。

在这里输入图像说明

我怎么能这样使用?

那是下面的方法吗?

- (NSString *)tableView:(UITableView *)tableView titleForFooterInSection:(NSInteger)section 

谢谢。

 - (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section { UIView *footer = [[UIView alloc]initWithFrame:CGRectMake(0, 0, 540, 10)]; footer.backgroundColor = [UIColor clearColor]; UILabel *lbl = [[UILabel alloc]initWithFrame:footer.frame]; lbl.backgroundColor = [UIColor clearColor]; lbl.text = @"Your Text"; lbl.textAlignment = NSTextAlignmentCenter; [footer addSubview:lbl]; return footer; } - (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section { return 10.0; } 

我宁愿把这个viewDidLoad() ,否则它会创build一种浮动效果,我不喜欢。 这里是我的解决scheme

  let footerView = UIView(frame:CGRectMake(0,0,self.view.frame.size.width,30)) footerView.backgroundColor = UIColor.clearColor() let footerLabel = UILabel(frame: footerView.frame) footerLabel.textColor = UIColor.flatGrayColor() footerLabel.textAlignment = NSTextAlignment.Center footerView.addSubview(footerLabel) footerLabel.text="\(self.items.count) Items"; self.tableView.tableFooterView=footerView