ios – 如何模仿UITableView的UITableViewStylePlain部分标题样式

我的应用程序使用UITableView部分标题中的缩写,VoiceOver很难发音.当我需要使这些标题可以由VoiceOver发音时,我需要给段标题一个accessibilityLabel.

似乎这样做的唯一方法是绘制一个自定义的部分标题单元格.我想模仿标准的Apple UIKit提供的这些自定义节标题的样式,但我不确定如何模仿苹果的这个元素的详细外观.

模拟UITableViewStylePlain部分标题样式的最佳方法是什么?

更新:我很清楚如何创建自定义标题单元格.我正在寻找的是一种技术来模仿Apple提供的标准单元格样式的简单UITableView部分标题单元格的外观.

解决方法

如果任何人仍然感兴趣,我已经看起来很亲密接下来的代码(使用Mark Adams的图片从上面的评论,但我调整了他们的大小,因为我的应用程序也有横向模式):
- (UIView *)tableView:(UITableView *)tbl viewForHeaderInSection:(NSInteger)section
{
    UIView* sectionHead = [[UIView alloc] initWithFrame:CGRectMake(0,tbl.bounds.size.width,18)];
    sectionHead.backgroundColor = [UIColor colorWithWhite:0 alpha:0];
    sectionHead.userInteractionEnabled = YES;
    sectionHead.tag = section;

    UIImageView *headerImage = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"PlainTableViewSectionHeader.png"]];
    headerImage.contentMode = UIViewContentModeScaleAspectFit;

    [sectionHead addSubview:headerImage];
    [headerImage release];

    UILabel *sectionText = [[UILabel alloc] initWithFrame:CGRectMake(10,2,tbl.bounds.size.width - 10,18)];
    sectionText.text = text;
    sectionText.backgroundColor = [UIColor clearColor];
    sectionText.textColor = [UIColor whiteColor];
    sectionText.shadowColor = [UIColor darkGrayColor];
    sectionText.shadowOffset = CGSizeMake(0,1);
    sectionText.font = [UIFont boldSystemFontOfSize:18];

    [sectionHead addSubview:sectionText];
    [sectionText release];

    return [sectionHead autorelease];
}

相关文章

当我们远离最新的 iOS 16 更新版本时,我们听到了困扰 Apple...
欧版/美版 特别说一下,美版选错了 可能会永久丧失4G,不过只...
一般在接外包的时候, 通常第三方需要安装你的app进行测...
前言为了让更多的人永远记住12月13日,各大厂都在这一天将应...