2015-12-12 43 views
0

我希望有一種方法來更改其單元格的textLabeldetailTextLabel項目的UITableView的文本的默認顏色。 AppDelegate中的一些代碼會將其從黑色更改爲其他自定義顏色。更改默認顏色的UITableView的textLabel和detailTextLabel

我的應用程序的顏色變得有點令人費解,這將是一個更加簡單的解決方案比明確地改變它:

cell.textLabel.textColor = UIColor.blueColor() 
+0

Ta柳告訴我你的確切解決方案 – user3182143

回答

1

剛剛創建的UITableViewCell的子類,改變文字顏色,然後讓所有其他您的應用中的UITableViewCell子類從此「父」單元繼承。

0

您可以通過在AppDelegate

[[UILabel appearance] setTextColor:[UIColor redColor]];

使用UIAppearance替換紅色與您想要的顏色做到這一點。顏色將是默認顏色,您仍然可以覆蓋每個標籤。在AppDelegate.h

0

add方法在AppDelegate.m

-(void)SetLabelTextColourForLabel:(UILabel*)Label 
{ 
    [Label setTextColor:[UIColor redColor]]; 
} 

-(void)SetLabelTextColourForLabel:(UILabel*)Label; 

add方法的實現和調用的cellForRowAtIndexPath方法

AppDelegate *app= (AppDelegate*)[[UIApplication sharedApplication] delegate]; 

    [app SetLabelTextColourForLabel:cell.textLabel]; 
    [app SetLabelTextColourForLabel:cell.detailTextLabel]; 

希望這將解決您的問題。