Skip to content

Commit f33418b

Browse files
committed
feat: add @UsesAutoLayout
1 parent e50c8f6 commit f33418b

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
//
2+
// UsesAutoLayout.swift
3+
// Swutil
4+
//
5+
// Created by Lucas Fernandez Nicolau on 25/08/22.
6+
//
7+
// Source: https://www.avanderlee.com/swift/auto-layout-programmatically/
8+
//
9+
10+
import UIKit
11+
12+
@propertyWrapper
13+
public final class UsesAutoLayout<T: UIView> {
14+
public var wrappedValue: T {
15+
didSet {
16+
wrappedValue.translatesAutoresizingMaskIntoConstraints = false
17+
}
18+
}
19+
20+
public init(wrappedValue: T) {
21+
self.wrappedValue = wrappedValue
22+
wrappedValue.translatesAutoresizingMaskIntoConstraints = false
23+
}
24+
}

0 commit comments

Comments
 (0)