UITableViewCell footer text in iOS

I want to make the following drawing.

enter image description here

How can i do this?

Is this the next method?

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

Thank.

+2
ios cocoa-touch uitableview
Feb 06 '13 at 8:16
source share
2 answers
 - (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; } 
+7
Feb 06 '13 at 8:18
source share

I would rather place this in viewDidLoad() , otherwise it will create a kind of floating effect, which I don't prefer. here is my solution in quick

  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 
0
Jul 04 '16 at 3:15
source share



All Articles