I find that UITableViewCell's
accessoryView
has a gray background color on iOS 13, but it works fine in system settings.
I have tried set the UITableView
background color and tint color none of them worked.
var cell = tableView.dequeueReusableCell(withIdentifier: "myInfo")
if (cell==nil) {
cell = UITableViewCell.init(style: UITableViewCell.CellStyle.default, reuseIdentifier: "myInfo")
}
cell!.accessoryType = .disclosureIndicator
The hierarchy in Xcode debug hierarchy view:
The reason looks like from the system imageView:
I have also noticed this issue. Even if you assign a disclosure indicator to the accessoryView, the view still returns nil. I have been waiting for Apple to fix this but it doesn't seem like they will anytime soon. Therefore, I created an extension on UITableViewCell to handle iOS13 and previous iOS builds.
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
}
}
}
I hope this helps. Below is a screenshot of two simulators with one running iOS12.2 and the other iOS13. The app is called seventytwo.
iOS12.2 vs. iOS13 Screenshot
I have the same problem in my cell, and my workaround is to inherit UITableViewCell, then use the custom image in the accessoryView。
self.accessoryView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"icon_arrow"]];
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With