gpt4 book ai didi

iphone - UITableView 中的自定义布局

转载 作者:行者123 更新时间:2023-11-28 19:13:17 25 4
gpt4 key购买 nike

我正在编写一个 iPhone 应用程序,其中使用了一个包含多个部分的 UITableView;每个部分都有一个标题,然后是它的行,如下所示:

enter image description here

通过使用自定义 UITableViewCell 对象,我可以正确地设置行样式,但是如何设置标题?如您所见:

  1. 标题的文本居中,从中画出两条线,每边各画一条
  2. 标题颜色不同
  3. 每个部分的角也是圆的

如何以编程方式或使用 Storyboard 实现这一点?

最佳答案

- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section

此方法作为 UITableViewDelegate 的一部分实现,旨在允许您为 UITableView 中的标题创建自定义 View 。您可以从该方法返回任何 UIView,无论它是您想在 Interface Builder 中还是在代码中创建的。

关于iphone - UITableView 中的自定义布局,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13779834/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com