Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/bielikb/UseAutoLayout
UseAutoLayout @propertyWrapper for Swift
https://github.com/bielikb/UseAutoLayout
autolayout property-wrapper swift
Last synced: 3 months ago
JSON representation
UseAutoLayout @propertyWrapper for Swift
- Host: GitHub
- URL: https://github.com/bielikb/UseAutoLayout
- Owner: bielikb
- License: mit
- Created: 2019-09-14T00:11:54.000Z (about 5 years ago)
- Default Branch: master
- Last Pushed: 2019-09-14T20:42:12.000Z (about 5 years ago)
- Last Synced: 2024-07-11T07:34:33.409Z (4 months ago)
- Topics: autolayout, property-wrapper, swift
- Language: Swift
- Homepage:
- Size: 2.18 MB
- Stars: 25
- Watchers: 3
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# @UseAutoLayout
Property wrapper that enables autolayout on applied views.# Declaration:
`@UseAutoLayout` property wrapper
```
@propertyWrapper
public struct UseAutoLayout {
public var wrappedValue: T {
didSet {
setAutoLayout()
}
}public init(wrappedValue: T) {
self.wrappedValue = wrappedValue
setAutoLayout()
}func setAutoLayout() {
wrappedValue.translatesAutoresizingMaskIntoConstraints = false
}
}
```# Usage
```
@UseAutoLayout var label = UILabel()
```## Installation
Property wrappers are defined in Swift 5.1.
Using @UseAutoLayout requires Xcode 11.0(and above) and Swift 5.1 toolchain### Swift Package Manager
Add
`.package(url: "https://github.com/bielikb/UseAutoLayout.git", from: "1.0.0")`
to your `Package.swift` file's `dependencies`.If youre using Xcode 11.0 add this Swift Package to your target(s) using Xcode.
# Example
![Sample](assets/autolayout-1.png)
---
![](assets/autolayout-2.png)