0

I have a nib where I set the background of a UICollectionCell to be a "Named Colour", i.e. one that I have specified in my asset library. Now in my cellForItem code I specify the background colour to be something different.

However, when the app first loads up, the colour of the cell is my "Named Colour" and NOT my programmatically defined one. If I make the cell reload its data (by pushing it offscreen and then onscreen again), it changes to the programmatically defined colour and stays like that.

Why? And how can I stop that from happening?

Tometoyou
  • 7,792
  • 12
  • 62
  • 108
  • I've recently asked for similar question. Is it what you're looking for? [Can't programmatically change color set in storyboard as color from xcassets catalog](https://stackoverflow.com/questions/53583593/cant-programmatically-change-color-set-in-storyboard-as-color-from-xcassets-cat) – Robert Dresler Jan 09 '19 at 16:58

1 Answers1

2

Have the same issue. Set the Color in the interface builder to the DEFAULT color. Then changing the color programmatically works.

Klinki
  • 368
  • 1
  • 11
  • This should be the accepted answer. When you aren't using a `UITableViewCell`, but a simple `UIView` and don't want the `UIViewController` to have to know about the implementation details (such as color) of the view, this is the only working solution. – Dávid Pásztor Oct 09 '19 at 15:34