wrong-size buttons get white artifact when rendering layer in 7.0 (11A4414e)

Originator:igeek1
Number:rdar://14417077 Date Originated:11-Jul-2013 02:49 PM
Status:Resolved Resolved:10-Mar-2016 01:49 PM
Product:iOS Product Version:7.0 (11A4414e)
Classification:UI/Usability Reproducible:Always
 
Summary: If you have a button that is a different size than its image, and you render the superlayer in a graphics context, the button in the image gets a white artifact on it.

Steps to Reproduce:
1. Open and run the sample code. The button in the storyboard is smaller than the image it contains, e.g. as the result of a miscommunication between the designer and the developer, so the graphic is getting resized. This is not desirable for a shipping app, but it is correct for this demonstration.

Look at the storyboard. It contains an empty UIImageView below a button. When the app runs, the view controller's view's layer is rendered into a graphics context, and the resulting image is set as the image view's image.


Expected Results:
The button in the screenshot looks exactly like the live button in the UI.

Actual Results:
The button in the screenshot gets a white artifact at the bottom.

Regression:
This works correctly in the iOS 6 SDK running on iOS 6, but breaks when run on iOS 7 (using either the 6 or 7 SDK).

Notes:
iOS 7's new -[UIView snapshotView] method does not suffer from the artifact problem, which you can see if you comment the first block of code and uncomment the second block of code in the attached project. This is only an issue for apps that need to support versions of iOS prior to iOS 7.

Sample project at http://cl.ly/fOxy

Comments

Me on 11-Mar-2016 06:04 PM

I don't have iOS 6 or 7 available to reproduce, but this issue does not reproduce with the iOS 9.3 simulator in Xcode 7.3 beta 5 (7D162j)

This issue has been verified as resolved and can be closed.

Apple Developer Relations on 10-Mar-2016 01:49 PM

Do you still see this issue in the latest iOS GM release?

Please test with this release. If you still have issues, please update your bug report with any relevant logs or information that could help us investigate.

iOS https://developer.apple.com/ios/download/

Me on 29-Jul-2013 04:32 PM

Yes, I have run the attached sample code in Beta 4, and the white artifact still shows up. It continues to work correctly if I comment out this block:

UIGraphicsBeginImageContextWithOptions(self.view.frame.size, YES, 0);
[self.view.layer renderInContext:UIGraphicsGetCurrentContext()];
UIImage *image = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
self.imageView.image = image;

and replace it with this block:

UIView *snapshot = [self.view snapshotViewAfterScreenUpdates:NO];
snapshot.frame = self.imageView.frame;
[self.view addSubview:snapshot];

(note the use of the new -snapshotViewAfterScreenUpdates: method)

Apple Developer Relations on 29-Jul-2013 02:49 PM

Engineering has requested the following information in order to further investigate this issue:

Does this issue also occur with iOS 7 beta 4 (11A4435d)? Please verify with this release, and update your report with the results.


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!