Asset catalog alignment rects ignored unless left,bottom insets are non-zero

Originator:keith
Number:rdar://27904825 Date Originated:18-Aug-2016
Status:Duplicate/22868067 (Closed) Resolved:12-Apr-2017
Product:Developer Tools Product Version:Xcode 7.3.1
Classification:Other Bug Reproducible:Always
 
Summary:
Specifying an alignment rectangle for an image in the asset catalog only works if a non-zero value is specified for the left and bottom insets.

This makes it unusable when you need an alignment rectangle that has at least one of the insets zero (e.g. top:0, left: 0, bottom:20, right:20)

Steps to Reproduce:
1) Add an image named "MyImage" to the asset catalog and specify an alignment rect with the following values:
  left: 0, top: 0, bottom: 20, right: 20
2) In a view controller create a new image using the asset catalog and print the value of the alignmentRectInsets property:

        if let myImage = UIImage(named: "MyImage") {
            print(myImage.alignmentRectInsets)
        }

Expected Results:
The alignment rect of the image created from the asset catalog should match the values we specified in the asset catalog:

UIEdgeInsets(top: 0.0, left: 0.0, bottom: 20.0, right: 20.0)


Actual Results:
The alignment rect has default (zero) values for the four insets:

UIEdgeInsets(top: 0.0, left: 0.0, bottom: 0.0, right: 0.0)

Version:
Xcode Version 7.3.1 (7D1014)
OS X El Capitan Version 10.11.6

Notes:
Problem still exists with Xcode 8 beta 6

Comments

Resolved in Xcode 9

Problem does not exist in Xcode 9 beta 1


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!