boundingRectWithSize returns different values on device, simulator in iOS12

Hi,


I am seeing clipping of text in a UITextView which (historically) has been symptomatic of incorrect text measurements. While investigating this issue, we discovered that in the latest iOS 12 beta (iOS 12 build (16A5357b)) running on an iPhone X device, we are seeing a regression in the boundingRectWithSize method. Specifically, the value seems to come back too large on an actual device compared to a simulator.


If you run the following code:


NSString *text = @"x xxx xxx xxx xx xxxx, xx x xxxx xxxx xxx xxx xxxx xxxx xxxxx... xxx xxxxxx xxxxx x xxx xxxx xx xxxx x xxxxxx xx xxxx xx xxxxxxx xx x xxx xxxxxxxx... xxx xxxxxxxxxxx xx x xxxx xxx xxxxxxxx xxx xxxx xxxx xx xxxxxxxxxx xx xx xxxxxxx xx xxxx?";


CGRect boundingRect =

[text boundingRectWithSize:CGSizeMake(285, CGFLOAT_MAX)

options:(NSStringDrawingUsesLineFragmentOrigin | NSStringDrawingUsesFontLeading)

attributes:@{ NSFontAttributeName : [UIFont preferredFontForTextStyle:UIFontTextStyleBody] }

context:nil];


On the simulator, it shows:


Rect is {{0, 0}, {283.521484375, 152.287109375}}


When the code above is run on a physical iPhone X device running iOS 12 build (16A5357b), it shows:


Rect is {{0, 0}, {283.521484375, 169.393867505}}


Should I expect this difference between Simulator and a real device, or is this a bug?

Thanks!

boundingRectWithSize returns different values on device, simulator in iOS12
 
 
Q