【问题标题】:UITableViewCell reorder control clips view in iOS 13iOS 13 中的 UITableViewCell 重新排序控件剪辑视图
【发布时间】:2020-07-29 05:43:33
【问题描述】:

我在 UITableViewCell 中放置了一张背景图片,以使其更具视觉吸引力。在 iOS 13 中,背景图像被重新排序控件剪裁。

旧版本的操作系统不会发生这种情况。

代码很简单:

    // Put a border around mBackgroundImage. Make it slightly smaller than the size of the cell so that the border doesn't run all the way to the edges.
cell.mBackgroundImage.frame = CGRectMake(2, 2, cell.frame.size.width-4, cell.frame.size.height-4);
cell.mBackgroundImage.layer.cornerRadius = 4;
cell.mBackgroundImage.layer.borderColor = [UIColor colorWithWhite:0.92 alpha:1.0].CGColor;
cell.mBackgroundImage.layer.borderWidth = 1;
cell.mBackgroundImage.layer.backgroundColor = [UIColor colorWithRed:1.0 green:1.0 blue:0.95 alpha:1.0].CGColor;

有什么建议吗?

【问题讨论】:

  • 您是将mBackgroundImage 添加到cell 还是cellcontentView
  • mBackgroundImage 在单元格的 contentView 中。
  • 啊哈!我根据单元格的框架调整 mBackgroundImage 的大小,而不是 contentView 的框架。并且似乎 cell.contentView.clipsToBounds 的默认设置在 iOS 13 中已更改。如果我明确将其设置为 NO,我会得到所需的行为。感谢您为我指明正确的方向!
  • 再想一想,我认为可能发生的事情是 iOS 13 修复了以前版本的 iOS 中的一个错误:cell.contentView.clipsToBounds=YES 已被忽略。
  • 您应该在layoutSubviews 中操作图层。你的代码在哪里?

标签: ios objective-c swift iphone uitableview


【解决方案1】:

通过将 cell.contentView.clipsToBounds 设置为 NO 解决了问题。看起来 cell.contentView.clipsToBounds=YES 在 iOS 13 之前已被忽略。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-03-08
    • 2010-11-22
    • 1970-01-01
    • 2020-01-07
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多