iOS 8-9 UIViewContentModeCenter does not snap UIImageView contents to pixel grid
Originator: | kevinchen2003 | ||
Number: | rdar://21526792 | Date Originated: | 24-Jun-2015 10:34 AM |
Status: | Open | Resolved: | |
Product: | iOS | Product Version: | iOS 8, all versions. iOS 9 beta 1 and 2. |
Classification: | Reproducible: | Always |
Summary: When creating a UIImageView, you can make it a larger size than the UIImage it contains. However, selecting someImageView.contentMode = UIViewContentModeCenter will cause the image to be blurry because its origin contains a fractional pixel. I'm not sure if this is a UIImageView bug or a UIView bug. Steps to Reproduce: I attached a project with sample code, but here is the important part: iconImageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"foo.png"]]; iconImageView.contentMode = UIViewContentModeCenter; // Add 1 px (which is a fractional point on retina devices) to the image view's height. The image view will try to leave 0.5 px of blank space on the top and bottom, causing the blurry icon. iconImageView.frame = CGRectMake(0, 0, iconImageView.frame.size.width, iconImageView.frame.size.height + 1 / [UIScreen mainScreen].scale); Expected Results: The image is as close to centered as possible, within the constraint of snapping it to the pixel grid Actual Results: When calculating the image's coordinates, UIKit doesn't seem to round to the pixel grid. Version: iOS 8, all versions. iOS 9 beta 1 and 2. Notes: This behavior does not happen on iOS 7 Configuration: Physical device and simulators: iPhone 5s, iPhone 6, iPhone 6 Plus, iPad Air Attachments: 'UIImageViewBlurryBug.zip' was successfully uploaded. http://cl.ly/0K3b38392m1i
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!