Avoid using UIView::frame in favor of bounds/center #691
Reference in New Issue
Block a user
No description provided.
Delete Branch "lmr--avoid-using-uiview-frame"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Currently YogaKit sets UIView's
frame
property directly, which is actually a computed property. This works fine when theUIView
doesnt have atransform
property set, but when it does then UIKit will invert the transform, set the center/bounds then reapply the transform in such a way that the transformed view's frame will be the frame that was set. This is not usually what you want... you usually want to set the frame of the non-transformed view, and then apply the transform on that frame without affecting layout.I believe this will improve performance since
bounds
andcenter
are not calculated properties, but I have not measured/verified.For people not using transforms, this should be a non-breaking change. If someone is using transforms with YogaKit, this may change the behavior, although I would argue this will produce the expected results (ie, transforms not being affected/altered by layout).
@@ -460,0 +467,4 @@
};
view.bounds = (CGRect) {
.origin = CGPointZero,
Hi @lelandrichardson, to handle correctly the view's layer.anchorPoint and to keep the view's bounds.origin, you should update your code to something like that. This thing is little tricky. UIScrollView's bounds.origin is not .zero when a contentOffset is set.
It looks like this PR has had an unactioned request for changes for some time. Going to take the liberty of closing it out, but feel free to reopen.
Pull request closed