【问题标题】:Let UIImageView in header section of UITableView overlap the content cells让 UITableView 标题部分中的 UIImageView 与内容单元格重叠
【发布时间】:2015-09-30 09:28:16
【问题描述】:

我想在表格视图中有一个带有徽标和名称的标题部分。现在,我希望徽标与下面内容单元格中的图像重叠。我在下面附上了一个例子:-

这是我到目前为止所尝试的,我尝试将标题部分的大小设为(徽标 + 上下填充)的一半——这只是将徽标切成两半

我也试过 clipToBounds :-

func tableView(tableView: UITableView, heightForHeaderInSection section: Int) -> CGFloat {
    return 33.0
}



func tableView(tableView: UITableView, viewForHeaderInSection section: Int) -> UIView? {

    let cell = tableView.dequeueReusableCellWithIdentifier("headerCell") as! FeedTableViewHeaderCell
    cell.designerNameLabel.text = "Vitamin A"
    cell.designerLogoImageView.image = UIImage(named: "zeko_small")
    cell.designerLogoImageView.clipsToBounds = false
    cell.contentView.clipsToBounds = false
    return cell

}

【问题讨论】:

  • 1.标题部分与单元格重叠。 2. Header部分有透明区域。
  • 你有没有尝试过?如果有,请出示代码。

标签: ios objective-c xcode swift uitableview


【解决方案1】:

您可以将ImageViewFrameHeight 设置为大于TableViewHeaderHeight 并在您的TableHeaderViewCell 中设置

TableHeaderViewCell.contentView.clipsToSubview = NO.

这肯定会帮助您获得结果。

XCode 7 的视觉指南:

【讨论】:

  • Xcode7 和 Swift 中没有 clipsToSubview?我已经完成了 clipToBounds
  • @rohan23 你哪里出错了,请看上面的图片并解决它..
【解决方案2】:

请使用此方法并根据需要设置您的部分标题高度。

func tableView(tableView: UITableView, heightForHeaderInSection section: Int) -> CGFloat {
        return 100// return height which is greater than your image's height.
    }

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-02-28
    • 1970-01-01
    • 2023-03-05
    相关资源
    最近更新 更多