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:
committed by
Facebook Github Bot
parent
15309d2bdd
commit
76fbd628e1
@@ -21,3 +21,7 @@ view.yoga.margin = 10
|
|||||||
view.yoga.marginTop // 0
|
view.yoga.marginTop // 0
|
||||||
view.yoga.marginLeft // 0
|
view.yoga.marginLeft // 0
|
||||||
```
|
```
|
||||||
|
|
||||||
|
### Enhancements
|
||||||
|
|
||||||
|
- Pixel Rounding now uses `roundf()` instead of `round()`.
|
||||||
|
@@ -353,7 +353,7 @@ static CGFloat YGRoundPixelValue(CGFloat value)
|
|||||||
scale = [UIScreen mainScreen].scale;
|
scale = [UIScreen mainScreen].scale;
|
||||||
});
|
});
|
||||||
|
|
||||||
return round(value * scale) / scale;
|
return roundf(value * scale) / scale;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void YGApplyLayoutToViewHierarchy(UIView *view, BOOL preserveOrigin)
|
static void YGApplyLayoutToViewHierarchy(UIView *view, BOOL preserveOrigin)
|
||||||
|
Reference in New Issue
Block a user