0

I'm new on iOS and so sorry for my bad english. I want to change the appearance theme to my application through the UIAppearance proxy. Then I have some different cells that are a subclass of UITableViewCell with a style for each one. Some labels in some cells have a different color, so that the "textLabel" property of the cell may have white color in a cell and red color in another.

I have a UILabel subclass, for example, for red color of text. I change the appearance color for this label as follows:

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

I want to use the same cell so what I did was Overwrite the method like this:

-(UILabel*) textLabel {
   //(MyRedLabel is only put for test purposes, lastly I'll remove it by a property that        will be what I want)
   return [[MyRedLabel alloc] initWithFrame:CGRectMake(0, 0, 0, 0)];
}

The problem is that when TableView draws the cells, text is not. Please can you help me? Thanks.

[EDIT]

Sorry if I don't explained. I have a UILabel's subclass for each color that I want, so if I want blue label I do this:

[[MyBlueLabel appearance] setTextLabel:[UIColor blueColor]]; 

I want is assign the label that I want to a cell:

//Cell1
MyCell *cell = [tableView dequeueReusableCellWithIdentifier:@"Identifier"];

if (cell == nil) {
    cell = [[[MyCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:CellIdentifier] autorelease];
}

cell.textLabel = [[MyBlueLabel alloc] initWithFrame:CGRectMake(0, 0, 0, 0)];
//...
//Cell2

//....  
cell.textLabel = [[MyRedLabel alloc] initWithFrame:CGRectMake(0, 0, 0, 0)];

Then when I do cell.textLabel.text = @"Hi world"; the text will be blue in cell1 and red in cell2.

I want to know if this is correct because I don't want to create 4 or more custom cells with his .xib

fras
  • 1
  • 2

1 Answers1

0

Not clear what you are asking. But you should not use [MyReadLabel appearance] to set the properties unless you want all you UILabel behaves in the same way. In your case like what you have said, i think you have misused the methods.

Simon
  • 237
  • 1
  • 7