2
我想要像下面的圖片一樣做。UITableViewCell在iOS中的頁腳文本
我該怎麼做才能使用這樣呢?
那是下面的方法嗎?
- (NSString *)tableView:(UITableView *)tableView titleForFooterInSection:(NSInteger)section
謝謝。
我想要像下面的圖片一樣做。UITableViewCell在iOS中的頁腳文本
我該怎麼做才能使用這樣呢?
那是下面的方法嗎?
- (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()
否則會造成排序的浮動效果,我不喜歡。這裏是我的解決方案
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
只需添加footer.backgroundColor = [UIColor clearColor]或其他顏色。也加上你的標籤。 –
謝謝你兄弟。 :) –
如果一切正確,則有效答案;)Thx –