【问题标题】:How to customize UIView of sections in UITableView?如何自定义 UITableView 中部分的 UIView?
【发布时间】:2016-09-16 14:43:35
【问题描述】:

我想在 UITableView 中设置我的部分的样式,例如 viewForFooterInSectionviewForHeaderInSection

我只能使用titleForHeaderInSection 设置标题,使用heightForHeaderInSection 设置高度,但我想设置背景颜色、字体大小、字体颜色等...

有可能吗?

【问题讨论】:

  • 是的,创建 UIView 并实现 viewForHeaderInSection 然后返回你的视图。
  • 您可以对部分页眉和页脚的视图进行任何操作。请澄清您遇到了什么麻烦。你的问题不是很清楚。

标签: ios objective-c uitableview uiview


【解决方案1】:

你可以用苹果提供的这个委托方法来做到这一点。

//for header 
- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
{
     UIView *myview = [[UIView alloc] init];
    //give size for veiw, background color, add label anything here



    return myview;
}


//for footer

- (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section
{
    UIView *myview = [[UIView alloc] init];
    //give size for veiw, background color, add label anything here



    return myview;
}

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-03-14
    • 1970-01-01
    • 1970-01-01
    • 2023-03-14
    • 2023-03-18
    相关资源
    最近更新 更多