2015-12-24 27 views
1

我正在嘗試更改UITableViewCell中的文本顏色,使用appearanceWhenContainedInInstancesOfClasses作爲其應用中的主題。UItableViewCell setTextColor已棄用

下面是代碼行:

[[UITableViewCell appearanceWhenContainedInInstancesOfClasses:@[[SearchTableView class]]] setTextColor:snackOrangeColor]; 

這工作。但setTextColor在iOS 3.0中已被棄用。因此,我無法使用它。我還找不到合適的解決方案。

我的問題是我應該用什麼來改變UITableViewCell中的文本顏色代替setTextColor?

感謝您的幫助。

回答

2

嘗試更改單元格的textLabel的textColor。

cell.textLabel.textColor = [UIColor someColor]; 

創建一個自定義的UITableViewCell

[[UILabel appearanceWhenContainedIn:[CustomUITableViewCell class], nil] 
setTextColor:[UIColor someColor]]; 

我不認爲有將是這一個選擇。我建議在常量中創建顏色,並在代碼中調用常量。

+0

我知道這個方法。但我需要使用UIAppearance,因爲我正在爲該應用製作主題。 –

+0

我想這是做到這一點的唯一方法。謝謝。 –

1

爲單元格創建自定義類,然後拖動和OUTLET的UILabel。然後使用該自定義單元格。

+0

感謝您的回答。 –

+0

@ s.d。沒關係。你可能會發現它有用 - http://code.tutsplus.com/tutorials/ios-sdk-crafting-custom-uitableview-cells--mobile-15702 –

1

對於你將是正確的添加「爲textLabel」

[[UITableViewCell appearanceWhenContainedInInstancesOfClasses:@[[SearchTableView class]]].textLabel setTextColor:snackOrangeColor];