我发现它UITableViewCell's accessoryView在 iOS 13 上有灰色背景色,但它在系统设置中运行良好。
我试过设置UITableView背景颜色和色调颜色,它们都不起作用。
var cell = tableView.dequeueReusableCell(withIdentifier: "myInfo")
if (cell==nil) {
cell = UITableViewCell.init(style: UITableViewCell.CellStyle.default, reuseIdentifier: "myInfo")
}
cell!.accessoryType = .disclosureIndicator
Run Code Online (Sandbox Code Playgroud)
Xcode 调试层次视图中的层次结构:
原因从系统 imageView 看:
小智 6
我也注意到了这个问题。即使您为附件视图分配了一个披露指示符,该视图仍然返回 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
}
}
}
Run Code Online (Sandbox Code Playgroud)
我希望这有帮助。下面是两个模拟器的截图,一个运行 iOS12.2,另一个运行 iOS13。该应用程序名为七十二。
小智 1
我的单元格中也有同样的问题,我的解决方法是继承UITableViewCell,然后使用accessoryView\xe3\x80\x82中的自定义图像
\n\nself.accessoryView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"icon_arrow"]];\nRun Code Online (Sandbox Code Playgroud)\n
| 归档时间: |
|
| 查看次数: |
1284 次 |
| 最近记录: |