OGeek|极客世界-中国程序员成长平台

标题: iOS - 自定义部分标题边界问题 [打印本页]

作者: 菜鸟教程小白    时间: 2022-12-13 11:50
标题: iOS - 自定义部分标题边界问题

我正在尝试为我的分组单元格创建我自己的部分标题。当我使用以下代码创建它时,它看起来好像边界已关闭。更具体地说是 CGRect

的高度

enter image description here

- (UIView *)tableViewUITableView *)tableView viewForHeaderInSectionNSInteger)section
{
    UIView *header = [[[UIView alloc] initWithFrame:CGRectMake(0, 0, tableView.bounds.size.width, 50)] autorelease];
    [header setBackgroundColor:[UIColor clearColor]];

    UILabel *label = [[[UILabel alloc] initWithFrame:CGRectMake(10, 3, tableView.bounds.size.width, 18)] autorelease];
    label.textColor = [UIColor redColor];
    label.text = @"SOME TEXT";
    label.backgroundColor = [UIColor clearColor];

    [header addSubview:label];

    return header;
}

知道为什么高度不对吗?我错过了什么吗?



Best Answer-推荐答案


您是否还按照文档中的描述实现了 tableView:heightForHeaderInSection:?这应该为您的表返回 50。

关于iOS - 自定义部分标题边界问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9472468/






欢迎光临 OGeek|极客世界-中国程序员成长平台 (http://sqlite.in/) Powered by Discuz! X3.4