CALayer renderInContext method ignores maskedCorners property

Originator:argentumko
Number:rdar://41414439 Date Originated:June 25 2018
Status:Open Resolved:
Product:iOS + SDK Product Version:iOS 11.0+
Classification:UI/Usability Reproducible:Always
 
Area:
Core Animation

Summary:
Using CALayer.maskedCorners property to disable masking for some of the corners has no effect over the "snapshot" of the layer rendered using renderInContext method: it still draws the layer hierarchy with all four corners masked.

Steps to Reproduce:
1. Create a simple view hierarchy, with one of the views' layers configured as such:
        layer.masksToBounds = true
        layer.cornerRadius = 20
        layer.maskedCorners = [ .layerMaxXMinYCorner, .layerMinXMaxYCorner ]
2. At some point render the layer of this masked view using CALayer. renderInContext method (via UIGraphicsImageRenderer).

Expected Results:
Produced "snapshot" only has top-right and bottom-left corners rounded, as actually displayed on the screen.

Actual Results:
Produced "snapshot" has all four corners rounded, as if maskedCorners has its default value.

Version/Build:
iOS 11.0 and later; reproducible in iOS 12 beta 1.

Configuration:
Any device or simulator.

Comments

I think this is the cause of an issue I'm seeing on macOS 10.14.3. When dragging an NSCollectionViewItem a CALayer with two masked corners is displayed with all four masked.


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!