UIImage imageWithRenderingMode: has no effect if called after init line

Originator:nicholaspetersonmobile
Number:rdar://22206703 Date Originated:09-Aug-2015 07:14 PM
Status:Open Resolved:
Product:iOS SDK Product Version:iOS 7.0.0+
Classification:Other Bug Reproducible:Always
 
Summary:
UIImages imageWithRenderingMode: has no effect on images behavior in UIBarButtonItem unless it is called immediately after UIImage initialization and on the same line.

Example given in Swift, Identical behavior exists in Objective-C and can be reproduced with equivalent steps in either language

Steps to Reproduce:
1. Create new app
2. Create UIImage:
var image = UIImage.imageNamed("my-image")
image = image.imageWithRenderingMode(.AlwaysTemplate)
3. Create UIBarButtonItem
var barButton =  UIBarButtonItem(image: image, style: .Plain, target: nil, action: nil)
4. Add to any navigation bar with a tintColor set.
navigationItem.rightBarItem = barButton

Full Code:
var image = UIImage.imageNamed("my-image")
image = image.imageWithRenderingMode(.AlwaysTemplate)
var barButton =  UIBarButtonItem(image: image, style: .Plain, target: nil, action: nil)
navigationItem.rightBarButtonItem = barButton

Expected Results:
UIImage rendered with current value of UIToolBar.tintColor

var image = UIImage.imageNamed("my-image").imageWithRenderingMode(.AlwaysTemplate)
// should have identical behavior to 
var image = UIImage.imageNamed("my-image")
image = image.imageWithRenderingMode(.AlwaysTemplate)

Actual Results:
UIImage retains original coloring.

Inconsistent behavior based on how imageWithRenderingMode is called.

Version:
iOS 7.0.0+

Notes:
 

Configuration:
All iOS devices and simulator

Attachments:

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!