From c302e34ee037e1d0c8b7c89d0fe87ae800341ed8 Mon Sep 17 00:00:00 2001 From: vvveiii Date: Fri, 14 Aug 2020 22:17:54 +0800 Subject: [PATCH] [YogaKit] fix complie error with -Wc++11-narrowing --- YogaKit/Source/YGLayout.m | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/YogaKit/Source/YGLayout.m b/YogaKit/Source/YGLayout.m index 317f5caa..531823ba 100644 --- a/YogaKit/Source/YGLayout.m +++ b/YogaKit/Source/YGLayout.m @@ -522,8 +522,8 @@ static void YGApplyLayoutToViewHierarchy(UIView* view, BOOL preserveOrigin) { } : CGPointZero; const CGPoint bottomRight = { - topLeft.x + YGNodeLayoutGetWidth(node), - topLeft.y + YGNodeLayoutGetHeight(node), + .x = (CGFloat)(topLeft.x + YGNodeLayoutGetWidth(node)), + .y = (CGFloat)(topLeft.y + YGNodeLayoutGetHeight(node)), }; #if TARGET_OS_OSX @@ -531,8 +531,8 @@ static void YGApplyLayoutToViewHierarchy(UIView* view, BOOL preserveOrigin) { #else // use bounds/center and not frame if non-identity transform. const CGPoint origin = preserveOrigin ? (CGPoint) { - .x = view.center.x - CGRectGetWidth(view.bounds) * 0.5, - .y = view.center.y - CGRectGetHeight(view.bounds) * 0.5 + .x = (CGFloat)(view.center.x - CGRectGetWidth(view.bounds) * 0.5), + .y = (CGFloat)(view.center.y - CGRectGetHeight(view.bounds) * 0.5) } : CGPointZero; #endif @@ -552,7 +552,7 @@ static void YGApplyLayoutToViewHierarchy(UIView* view, BOOL preserveOrigin) { #if TARGET_OS_OSX if (!view.superview.isFlipped && view.superview.isYogaEnabled && view.superview.yoga.isEnabled) { - frame.origin.y = YGNodeLayoutGetHeight(view.superview.yoga.node) - CGRectGetMaxY(frame); + frame.origin.y = (CGFloat)(YGNodeLayoutGetHeight(view.superview.yoga.node) - CGRectGetMaxY(frame)); } view.frame = (CGRect) { @@ -566,8 +566,8 @@ static void YGApplyLayoutToViewHierarchy(UIView* view, BOOL preserveOrigin) { }; view.center = (CGPoint) { - .x = CGRectGetMinX(frame) + CGRectGetWidth(frame) * 0.5, - .y = CGRectGetMinY(frame) + CGRectGetHeight(frame) * 0.5 + .x = (CGFloat)(CGRectGetMinX(frame) + CGRectGetWidth(frame) * 0.5), + .y = (CGFloat)(CGRectGetMinY(frame) + CGRectGetHeight(frame) * 0.5) }; #endif