Xcode 9 doesn't always render UIImages as template based on autolayout constraints

Originator:jfriend
Number:rdar://44948383 Date Originated:02-Oct-2018 03:37 PM
Status:Open Resolved:
Product:iOS + SDK Product Version:Version 9.0 beta 6 (9M214v)
Classification:Serious Bug Reproducible:Always
 
Summary:
This is a duplicate of radar #34279759

Note that I am not sure whether this an iOS 11 SDK or Xcode 9 bug.

With Xcode 9 / iOS 11, images from the asset catalog with the rendering mode set to "Template Image" will be rendered as "Original Image" (i.e. without taking into account the tint color and alpha channel of the image) if the UIImageView displaying them has 2 or less "Spacing to nearest neighbor" autolayout constraint.


Steps to Reproduce:
1. Add a new image to your asset catalog
2. Set the image rendering mode to "Template Image"
3. Add a UIImageView to a storyboard / nib, and set its image to the image added in step 1
4. Position the UIImageView with at most 2 "spacing" constraints
   (For example, a Vertical Spacing to Top, a Horizontal Spacing to Left, a Width, and a Height constraints)

Expected Results:
The image is rendered as template, with its pixels where alpha = 1 taking the color of tintColor, and the other pixel as transparent.

Actual Results:
The image is rendered as "original", with its original colors.

Version:
Version 9.0 beta 6 (9M214v)

Notes:
See the attached project reproducing the problem. The two UIImageView use the same image with rendering mode set to "Template", but only one of the same actually is rendering as template.

This used to work fine pre-Xcode 9.

See also this SO answer explaining the same problem: https://stackoverflow.com/a/43524192/404321

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!