我也注意到了这个问题。即使您为附件视图分配了一个显示指示器,该视图仍然返回 nil。我一直在等待 Apple 解决这个问题,但他们似乎不会很快解决这个问题。因此,我在 UITableViewCell 上创建了一个扩展来处理 iOS13 和以前的 iOS 版本。
extension UITableViewCell {
func createCustomCellDisclosureIndicator(chevronColor: UIColor) {
//MARK: Custom Accessory View
//Chevron img
if #available(iOS 13.0, *) {
let chevronConfig = UIImage.SymbolConfiguration(pointSize: 14, weight: .medium)
guard let chevronImg = UIImage(systemName: "chevron.right", withConfiguration: chevronConfig)?.withTintColor(chevronColor, renderingMode: .alwaysTemplate) else { return }
let chevron = UIImageView(image: chevronImg)
chevron.tintColor = chevronColor
//chevron view
let accessoryViewHeight = self.frame.height
let customDisclosureIndicator = UIView(frame: CGRect(x: 0, y: 0, width: 15, height: accessoryViewHeight))
customDisclosureIndicator.addSubview(chevron)
//chevron constraints
chevron.translatesAutoresizingMaskIntoConstraints = false
chevron.trailingAnchor.constraint(equalTo: customDisclosureIndicator.trailingAnchor,constant: 0).isActive = true
chevron.centerYAnchor.constraint(equalTo: customDisclosureIndicator.centerYAnchor).isActive = true
//Assign the custom accessory view to the cell
customDisclosureIndicator.backgroundColor = .clear
self.accessoryView = customDisclosureIndicator
} else {
self.accessoryType = .disclosureIndicator
self.accessoryView?.tintColor = chevronColor
}
}
}
我希望这有帮助。下面是两个模拟器的截图,一个运行 iOS12.2,另一个运行 iOS13。该应用程序名为七十二。
iOS12.2 与 iOS13 截图