Sabo Sabo - 5 months ago 9
iOS Question

UITableViewCell's footer text in iOS

I want to do like following pic.

enter image description here

How can i do to use like that?

Is that following method?

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


Thanks.

Answer
- (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;
}