Needs is a small library that let you use a property wrapper to automatically call setNeeds-
methods.
It works out-of-the-box for all setNeeds-
methods available on UIView
, UIViewController
and NSView
.
If you need to you can also extend it with your own Need.
- iOS 9.0+ / macOS 10.10+
- Swift 5.2
Needs is available through CocoaPods and SwiftPM
Add a Needs
property wrapper to one of your properties to call automatically the desired setNeeds-
method
@Needs(.layout, .display)
var progress: CGFloat = 0
.display // self.setNeedsDisplay()
.layout // self.setNeedsLayout()
.updateConstraints // self.setNeedsUpdateConstraints()
.focusUpdate // self.setNeedsFocusUpdate()
.statusBarAppearanceUpdate // self.setNeedsStatusBarAppearanceUpdate()
.updateOfHomeIndicatorAutoHidden // self.setNeedsUpdateOfHomeIndicatorAutoHidden()
.updateOfScreenEdgesDeferringSystemGestures // self.setNeedsUpdateOfScreenEdgesDeferringSystemGestures()
.updateOfPrefersPointerLocked // self.setNeedsUpdateOfPrefersPointerLocked()
.userInterfaceAppearanceUpdate // self.setNeedsUserInterfaceAppearanceUpdate()
.focusUpdate // self.setNeedsFocusUpdate()
.viewDisplay // self.viewIfLoaded?.setNeedsDisplay()
.viewLayout // self.viewIfLoaded?.setNeedsLayout()
.updateViewConstraints // self.viewIfLoaded?.setNeedsUpdateConstraints()
.reloadData // self.tableView.reloadData()
.display // self.setNeedsDisplay($0.bounds)
.layout // self.needsLayout = true
.updateConstraints // self.needsUpdateConstraints = true
Needs is available under the MIT license. See the LICENSE file for more info.