在表格视图单元格中更改重新排序控件的颜色 [英] Change Reorder Control's color in table view cell
本文介绍了在表格视图单元格中更改重新排序控件的颜色的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在下图中,如何将视图右侧的按钮的颜色更改为白色?理想情况下,只希望某些单元格为白色而其他单元格为黑色这是我的代码:
In the image below, how do I change the color of the buttons on the right hand side of the view to white?edit: Ideally only want it to be white for certain cells and black for others Here's my code:
cell.backgroundColor = .appOrange
cell.contentLabel.textColor = .white
cell.numberLabel.textColor = .white
cell.tintColor = .white //this appears to do nothing, just something I tried
推荐答案
这适用于我使用iOS11和Swift 4的UITableViewController:
This works for me in my UITableViewController using iOS11 and Swift 4:
private var myReorderImage : UIImage? = nil;
override func tableView(_ tableView: UITableView, willDisplay cell: UITableViewCell, forRowAt indexPath: IndexPath) {
for subViewA in cell.subviews {
if (subViewA.classForCoder.description() == "UITableViewCellReorderControl") {
for subViewB in subViewA.subviews {
if (subViewB.isKind(of: UIImageView.classForCoder())) {
let imageView = subViewB as! UIImageView;
if (myReorderImage == nil) {
let myImage = imageView.image;
myReorderImage = myImage?.withRenderingMode(UIImageRenderingMode.alwaysTemplate);
}
imageView.image = myReorderImage;
imageView.tintColor = UIColor.red;
break;
}
}
break;
}
}
}
这篇关于在表格视图单元格中更改重新排序控件的颜色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文