Skip to content

Commit

Permalink
Drop the ceil calls.
Browse files Browse the repository at this point in the history
The `ceil` calls were added back when updating things for iOS 7, to model what
the older `-sizeWithFont:` call did. But looking back, Apple likely moved off
the api (and behavior) with the adoption of retina screens, so we should do the
fade calc based on the fractional sizes also, so we don't force a fade when the
string fully fits.
  • Loading branch information
thomasvl committed Mar 23, 2023
1 parent b7665e7 commit 1b2da5e
Showing 1 changed file with 0 additions and 3 deletions.
3 changes: 0 additions & 3 deletions iPhone/GTMFadeTruncatingLabel.m
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,6 @@ - (void)drawTextInRect:(CGRect)requestedRect {
CGSize size = CGSizeZero;
if (self.font) {
size = [self.text sizeWithAttributes:@{NSFontAttributeName:self.font}];
// sizeWithAttributes: may return fractional values, so ceil the width and
// height to preserve the behavior of sizeWithFont:.
size = CGSizeMake(ceil(size.width), ceil(size.height));
}
if (size.width > requestedRect.size.width) {
UIImage* image = [[self class]
Expand Down

0 comments on commit 1b2da5e

Please sign in to comment.