Skip to content

Commit 0b7e265

Browse files
committed
Update CustomTableViewCell.swift
1 parent 79f2094 commit 0b7e265

File tree

1 file changed

+21
-5
lines changed

1 file changed

+21
-5
lines changed

AAInfographicsDemo/Demo/AdditionalContent2/CustomTableViewCell.swift

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,17 +28,33 @@ class CustomTableViewCell: UITableViewCell {
2828

2929
// 更新颜色以支持夜间模式
3030
func updateColors() {
31-
backgroundColor = UIColor.systemBackground
32-
contentView.backgroundColor = UIColor.systemBackground
33-
titleLabel.textColor = UIColor.label
31+
if #available(iOS 13.0, *) {
32+
backgroundColor = UIColor.systemBackground
33+
} else {
34+
// Fallback on earlier versions
35+
}
36+
if #available(iOS 13.0, *) {
37+
contentView.backgroundColor = UIColor.systemBackground
38+
} else {
39+
// Fallback on earlier versions
40+
}
41+
if #available(iOS 13.0, *) {
42+
titleLabel.textColor = UIColor.label
43+
} else {
44+
// Fallback on earlier versions
45+
}
3446
numberLabel.textColor = UIColor.white
3547
}
3648

3749
override func traitCollectionDidChange(_ previousTraitCollection: UITraitCollection?) {
3850
super.traitCollectionDidChange(previousTraitCollection)
3951
// 当用户界面样式发生变化时重新更新颜色
40-
if traitCollection.hasDifferentColorAppearance(comparedTo: previousTraitCollection) {
41-
updateColors()
52+
if #available(iOS 13.0, *) {
53+
if traitCollection.hasDifferentColorAppearance(comparedTo: previousTraitCollection) {
54+
updateColors()
55+
}
56+
} else {
57+
// Fallback on earlier versions
4258
}
4359
}
4460
}

0 commit comments

Comments
 (0)