天天看點

【iOS 1 行代碼系列】之 一行代碼搞定TableView組頭懸停

場景:

當 ​

​UITableView​

​​ 的 ​

​style​

​​ 屬性設定為 ​

​Plain​

​​ 時

​​

​tableview​

​​ 的 ​

​section header​

​​ 在滾動到界面頂端時

會 ​​

​懸停​

​ !

疑問:

1.如何在不使用​

​Grouped​

​​時,讓組頭不懸停??

2.如何在不重寫​​

​-scrollViewDidScroll:​

​​ (​​示例​​) 方法時,讓組頭不懸停???

辦法:

- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section{
    UIView *view = [[UIView alloc] init];
    view.frame = CGRectMake(0, 0, kScreenWidth, 10);
    view.backgroundColor = [UIColor clearColor];
    return