我做了一個演示工作正常。 我被卡住了一點。如何設置底線爲UITableview單元的標題?
圖片
問題
1)如何讓這種類型的功能,頁眉和波紋管頭狀態,日期和評論?
2)如何在單元格和標題之間設置下劃線「看它是淺灰色」?
我做了一個演示工作正常。 我被卡住了一點。如何設置底線爲UITableview單元的標題?
1)如何讓這種類型的功能,頁眉和波紋管頭狀態,日期和評論?
2)如何在單元格和標題之間設置下劃線「看它是淺灰色」?
1.您可以在UITableViewDelegate
的此功能中返回標題視圖。
optional public func tableView(tableView: UITableView, viewForHeaderInSection section: Int) -> UIView?
// custom view for header. will be adjusted to default or specified header height
2.You可以編程方式添加該行或嘗試表格視圖的樣式設置爲Plain
。
請給我在客觀的c – user7018875
Plase請在viewForHeaderInSection
func tableView(tableView: UITableView, viewForHeaderInSection section: Int) -> UIView? {
/// create your custom view//
return customView;
}
1.創建自定義視圖自定義視圖,但是你想(像你像貼)
2.Return,在這種方法
查看作爲報頭部分- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
使用此委託方法。
-(UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section{
UIView *headerView=[[UIView alloc] initWithFrame:CGRectMake(0, 0, tableView.frame.size.width, HEADER_H)];
UIView *lineView=[[UIView alloc] initWithFrame:CGRectMake(0, HEADER_H-2, tableView.frame.size.width, 1)];
lineView.backgroundColor=[UIColor darkGrayColor];
[headerView addSubview:lineView];
return headerView;
}
創建您的自定義視圖,並在'UITableViewDelegate'的'viewForHeaderInSection'方法中返回該視圖。 –
@NiravD但他希望它爲每個單元格 – Himanth
不,我只想從頭和單元格,而不是每個單元格 – user7018875