File tree Expand file tree Collapse file tree 1 file changed +21
-5
lines changed
AAInfographicsDemo/Demo/AdditionalContent2 Expand file tree Collapse file tree 1 file changed +21
-5
lines changed Original file line number Diff line number Diff 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}
You can’t perform that action at this time.
0 commit comments