Skip to main content

Traps

Don't use @QuickLayout macro on UIViewControllers

See this page for integration with UIViewControllers.

@QuickLayout /// <-- 🛑 Don't use the macro on UIViewControllers
final class MyViewController: UIViewController {

var body: Layout {
...
}
}
DON'T

When using @QuickLayout, don't call body.applyFrame(). This will result in double measurements.

@QuickLayout
final class VerySlowView: UIView {

var body: Layout {
...
}

/// @QuickLayout macro will insert additional
/// _QuickLayoutViewImplementation call into this method.
override func layoutSubviews() {
super.layoutSubviews()
body.applyFrame(self.bounds) /// <-- 🛑 Don't call applyFrame when using @QuickLayout macro
}
}
Don't create views in the body
@QuickLayout
final class MyView: UIView {

var body: Layout {
HStack {
UIView() /// <-- 🛑 Don't create views in the body
}
}
}