我发现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
Xcode调试层次结构视图中的层次结构:
原因从系统imageView看起来像:
答案 0 :(得分:2)
我也注意到了这个问题。即使将附件指示符分配给了附件视图,该视图仍然返回nil。我一直在等待苹果公司解决此问题,但似乎他们不会很快来。因此,我在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。该应用程序称为72。
答案 1 :(得分:1)
我的单元格中有同样的问题,我的解决方法是继承UITableViewCell,然后在附件视图中使用自定义图像。
self.accessoryView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"icon_arrow"]];