Overriding layerClass, however still need to force cast layer as type

Originator:benjamin
Number:rdar://30776848 Date Originated:1/3/2017
Status:Open Resolved:No
Product:iOS + SDK Product Version:
Classification:Core Animation Reproducible:Always
 
When overriding a UIView's backing layerClass, the change does not propagate immediately to the compiler. Upon accessing the view's layer property, it sees type CALayer. This is despite the fact that it may be CAGradientLayer for example, or any other type of custom CALayer implementation/extension/subclass.

Steps to Reproduce:
1. Override UIView layerClass from CALayer to CAGradientLayer for example.
2. Try to set the .colors of the layer in viewDidLoad() for example.
3. Find that the layer has no property of colors. The layer needs to be force cast to CAGradientLayer before it has the required/desired properties.


Expected Results:
1. Override UIView layerClass from CALayer to <Other CALayer>
2. Use properties of new type of layer without requiring force cast.

Actual Results:
Still requires force cast.

Comments


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!