Use correct rounding function when rounding pixels.

Summary: While debugging something at Instagram, I kept seeing a UILabel be truncated when it clearly had enough room to display all its' text. What I realized is that during our pixel rounding, we were losing precision because we were using the incorrect rounding function for floats. Changing from `round()` (which is for doubles) to `roundf()` fixed it.

Reviewed By: amonshiz

Differential Revision: D4549069

fbshipit-source-id: 78a1bb33e315e7c066b7fb625b1f5a28def76515
This commit is contained in:
Dustin Shahidehpour
2017-02-11 19:45:35 -08:00
committed by Facebook Github Bot
parent 15309d2bdd
commit 76fbd628e1
2 changed files with 5 additions and 1 deletions

View File

@@ -21,3 +21,7 @@ view.yoga.margin = 10
view.yoga.marginTop // 0
view.yoga.marginLeft // 0
```
### Enhancements
- Pixel Rounding now uses `roundf()` instead of `round()`.

View File

@@ -353,7 +353,7 @@ static CGFloat YGRoundPixelValue(CGFloat value)
scale = [UIScreen mainScreen].scale;
});
return round(value * scale) / scale;
return roundf(value * scale) / scale;
}
static void YGApplyLayoutToViewHierarchy(UIView *view, BOOL preserveOrigin)