Search code examples
iosshadowappearance

UIAppearance proxy problems with appearanceWhenContainedIn


I am trying to give each label in my background view a shadow:

[[UILabel appearanceWhenContainedIn:[MyBackgroundView class], nil] setShadowColor:[UIColor colorWithWhite:0.6 alpha:1]];
[[UILabel appearanceWhenContainedIn:[MyBackgroundView class], nil] setShadowOffset:CGSizeMake(0, -1)];

The problem is that in my background view there are some subviews (a tableview for example) which cells' labels should not get this shadowColor.

I tried this by doing so:

[[UILabel appearanceWhenContainedIn:[MyBackgroundView class], nil] setShadowColor:[UIColor colorWithWhite:0.6 alpha:1]];
[[UILabel appearanceWhenContainedIn:[MyBackgroundView class], nil] setShadowOffset:CGSizeMake(0, -1)];
[[UILabel appearanceWhenContainedIn:[UITableViewCell class], nil] setShadowColor:[UIColor clearColor]];

But the text-shadow still exists in the tableviews' cells.

Can anybody tell me what I am doing wrong?!?


Solution

  • I would create a sub class of UILabel and set the shadow appearance on that.