hor*_*rst 15 uitableview accessorytype ios swift xcode6
我想将我的cell accessoryType的颜色从蓝色更改为白色.textColor已设置为白色.你们有人知道怎么做吗?
我的代码:
cell!.accessoryType = UITableViewCellAccessoryType.Checkmark
Osc*_*VGG 30
您可以将UITableViewCell tintColor属性设置为所需的颜色:
[cell setTintColor:[UIColor whiteColor]];
Run Code Online (Sandbox Code Playgroud)
Das*_*oga 13
迅速:
cell.tintColor = UIColor.whiteColor()
Run Code Online (Sandbox Code Playgroud)
Swift 3.0
cell.tintColor = UIColor.white
Run Code Online (Sandbox Code Playgroud)
Tun*_*Fam 11
.disclosureIndicator?如果有人在这里寻找“如何更改.disclosureIndicator指示器类型的颜色”。
答案是你不能。但:
有一种方法。应用自定义图像:
let chevronImageView = UIImageView(image: "disclosureIndicatorImage"))
accessoryView = chevronImageView
Run Code Online (Sandbox Code Playgroud)
其他支持链接:
“如何更改.disclosureIndicator指标类型的颜色”。经过大量研究,我注意到disclosureIndicator的图像不是Image而是backgroundImage。我找到了这样的解决方案:
import UIKit
class CustomCell: UITableViewCell {
fileprivate func commonInit() {
}
open override func layoutSubviews() {
super.layoutSubviews()
if let indicatorButton = allSubviews.compactMap({ $0 as? UIButton }).last {
let image = indicatorButton.backgroundImage(for: .normal)?.withRenderingMode(.alwaysTemplate)
indicatorButton.setBackgroundImage(image, for: .normal)
indicatorButton.tintColor = .red
}
}
}
extension UIView {
var allSubviews: [UIView] {
return subviews.flatMap { [$0] + $0.allSubviews }
}
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
17619 次 |
| 最近记录: |