New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Performance imporvement in UIView fillToSuperview() #540
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -457,10 +457,11 @@ public extension UIView { | |
// https://videos.letsbuildthatapp.com/ | ||
translatesAutoresizingMaskIntoConstraints = false | ||
if let superview = superview { | ||
leftAnchor.constraint(equalTo: superview.leftAnchor).isActive = true | ||
rightAnchor.constraint(equalTo: superview.rightAnchor).isActive = true | ||
topAnchor.constraint(equalTo: superview.topAnchor).isActive = true | ||
bottomAnchor.constraint(equalTo: superview.bottomAnchor).isActive = true | ||
let left = leftAnchor.constraint(equalTo: superview.leftAnchor) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hey @viktart :)) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The performance gain is because you're not supposed to activate constraints individually. It's better to activate them all at once using the |
||
let right = rightAnchor.constraint(equalTo: superview.rightAnchor) | ||
let top = topAnchor.constraint(equalTo: superview.topAnchor) | ||
let bottom = bottomAnchor.constraint(equalTo: superview.bottomAnchor) | ||
NSLayoutConstraint.activate([left, right, top, bottom]) | ||
} | ||
} | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, post merge regret. We should clean up this CHANGELOG entry in another PR 😕 My bad guys
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ooops, since I also approve my bad too :((
But it's simple I can fix it right :))