swift - UINavigationController 中的 tvOS UITableView 导致奇怪的褪色行为(UIView.mask)

标签 swift uitableview mask tvos

当在 UINavigationController 的上下文中使用 UITableView 时,我遇到了一个奇怪的情况。

tvOS 使用 UIView.mask 在 UITableView 的顶部和底部应用“淡出渐变”,以便单元格在表格 View 的顶部和底部边缘淡入和淡出。

没关系:淡化 mask 始终不会挡住所选单元格。

(此处,view.backgroundColor 设置为红色,tableView.backgroundColor 设置为蓝色,alpha 为 50%。tableView 的约束设置为安全区域。)

enter image description here

当您将 View Controller 放在 UINavigationController 中时,问题就来了。 When selection is near the top, the mask view no longer seems to avoid the cell, so it looks faded.此外,当用户向下滚动时,淡入淡出的 mask 向下跳了一大步,然后当用户开始向上滚动时,淡入淡出的 mask 似乎并没有挡住:

enter image description here

作为引用,这里是相同的设置,但 tableView.mask = nil:

enter image description here

(所有淡入淡出都被禁用,但您可以看到单元格在 tableview 的顶部和底部“弹出”和消失。您可能认为您可以设置 tableView.masksToBounds = true,但随后选定的单元格被砍掉,因为它在被选中时会增长)

我肯定在这里遗漏了一些明显的东西? Apple 没有人在导航 Controller 中放置一个 tableview 吗?

最佳答案

你们太亲密了!边界的剪辑丢失了。

tableView.clipsToBounds = true
tableView.mask = nil

干杯:)

关于swift - UINavigationController 中的 tvOS UITableView 导致奇怪的褪色行为(UIView.mask),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54560619/

相关文章:

ios - 优化 NSFetchedResultsController 支持的 UITableView

c++ - 如何 "zero"OpenCV 中图像蒙版部分内的所有内容

ios - 如何在 iOS 中屏蔽 UIView

ios - NSUserDefault 自定义对象错误 - "array cannot be bridged from Objective-C"

ios - UILabel 文本对齐不起作用(Swift 4)

objective-c - 在 Objective C header 中访问 Swift 类

swift - 将 Swift 2.0 转换为 Swift 3.0

swift - 根据按钮请求在表格 View 中隐藏和显示部分

Ios消息应用程序,如何控制键盘

ios - CAShapeLayer mask View