ios - UITableViewCell 突出显示覆盖我的自定义 View

标签 ios swift uitableview cell

我的应用程序中有一个自定义 UITableViewCell。我在初始化时向单元格添加了一个 View 。

class RestaurantCell: ListTableViewCell {
    public let stripeView: UIView = UIView()

    override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
        super.init(style: style, reuseIdentifier: reuseIdentifier)

        addSubview(stripeView)
    }
}

现在,当用户触摸应用程序时,灰色突出显示将覆盖我的自定义 View ,但不会覆盖 textLabeldetailTextLabel。 为了解决这个问题,我尝试在 textLabelselectedBackgroundView 上方添加 stripeView。那并没有解决问题。有什么想法吗?

最佳答案

您要添加的元素应该是“自定义 View ”的子元素,以便突出显示,您可以检查一下 textLabel 和DetailTextLabel 是否都是子元素吗?

关于ios - UITableViewCell 突出显示覆盖我的自定义 View ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56038735/

相关文章:

iphone - 如何在 didSelectRowAtIndexPath 中到达当前选定的单元格?

swift - UN用户通知中心。此应用程序不允许通知

ios - 如何在 tableView swift 中快速进行数组追加和排序

swift - Swift 中的共享变量

ios - 增加 NSIndexPath

ios - 有没有办法检查用户是否使用 Twitter 登录?

iphone - 如何在 iOS 中获取此模式?

IOS 显示应用程序在电池耗尽后在后台运行

ios - 如何将自定义类 UIButton 与同一类的另一个对象设置?

ios - iPhone 6/6 Plus : UITableView separator flickering and different thickness