Avoid using UIView::frame in favor of bounds/center
This commit is contained in:
@@ -451,15 +451,26 @@ static void YGApplyLayoutToViewHierarchy(UIView *view, BOOL preserveOrigin)
|
|||||||
topLeft.y + YGNodeLayoutGetHeight(node),
|
topLeft.y + YGNodeLayoutGetHeight(node),
|
||||||
};
|
};
|
||||||
|
|
||||||
const CGPoint origin = preserveOrigin ? view.frame.origin : CGPointZero;
|
const CGPoint origin = preserveOrigin ? (CGPoint){
|
||||||
view.frame = (CGRect) {
|
.x = view.center.x - (view.bounds.size.width / 2),
|
||||||
.origin = {
|
.y = view.center.y - (view.bounds.size.height / 2),
|
||||||
.x = YGRoundPixelValue(topLeft.x + origin.x),
|
} : CGPointZero;
|
||||||
.y = YGRoundPixelValue(topLeft.y + origin.y),
|
|
||||||
},
|
CGFloat x = topLeft.x + origin.x;
|
||||||
|
CGFloat y = topLeft.y + origin.y;
|
||||||
|
CGFloat width = bottomRight.x - topLeft.x;
|
||||||
|
CGFloat height = bottomRight.y - topLeft.y;
|
||||||
|
|
||||||
|
view.center = (CGPoint) {
|
||||||
|
.x = YGRoundPixelValue(x + (width / 2)),
|
||||||
|
.y = YGRoundPixelValue(y + (height / 2)),
|
||||||
|
};
|
||||||
|
|
||||||
|
view.bounds = (CGRect) {
|
||||||
|
.origin = CGPointZero,
|
||||||
.size = {
|
.size = {
|
||||||
.width = YGRoundPixelValue(bottomRight.x) - YGRoundPixelValue(topLeft.x),
|
.width = YGRoundPixelValue(width),
|
||||||
.height = YGRoundPixelValue(bottomRight.y) - YGRoundPixelValue(topLeft.y),
|
.height = YGRoundPixelValue(height),
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user