When using a colour asset in an IB document, the colour can't be changed programmatically

Originator:arnold.sakhnov
Number:rdar://36530826 Date Originated:January 16 2018
Status:DUPLICATE OF 36047874 Resolved:
Product:UIKit Product Version:iOS 11
Classification: Reproducible:
 
Summary:
When using new colour assets introduced in iOS 11 in an IB document (XIB or Storyboard), we aren't able to programmatically alter those colours at runtime. Because the system treats those colours as traits, they get re-applied to the element whenever it's laid out.

Steps to Reproduce:
* Create a sample project, with a Storyboard an and Asset Catalog.
* Add a red colour to the asset catalog, and call it "MyDefaultBackground".
* Set the background of the main View Controller in the Storyboard to "MyDefaultBackground".
* In viewDidLoad of the main View Controller, change the background of the view to anything else, e.g. green.

Expected Results:
The background colour of the view is changed to green and stays that way.

Actual Results:
The view remains "MyDefaultBackground" red, because UITraitCollection appears to enforce this colour to be re-applied when the view is laid out.

Version/Build:
iOS 11, Xcode 9.2

Comments

iOS 13 update

This is still an issues in iOS 12.2. This appears to be fixed in iOS 13 (Xcode 11b2).

By samsoffes at July 1, 2019, 5:41 p.m. (reply...)

Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!