UseAutoLayout

1.0.1

UseAutoLayout @propertyWrapper for Swift
bielikb/UseAutoLayout

What's New

Property wrapper hotfix

2019-09-14T20:22:12Z
  • unnecessary value was removed from the UseAutoLayout struct.
  • translatesAutoresizingMaskIntoConstraints = false is now set form within setAutoLayout function.
  • wrappedValue now invokes setAutoLayout in it's didSet observer.
  • setAutoLayout is called everytime when UseAutoLayout property wrapper is initialised or it's wrapper value changes.

Special thanks goes to Martin Kiss - https://github.com/Tricertops for co-op on this release!

@UseAutoLayout

Property wrapper that enables autolayout on applied views.

Declaration:

@UseAutoLayout property wrapper

@propertyWrapper
public struct UseAutoLayout<T: UIView> {
    var value: T

    public var wrappedValue: T {
      get { return value }
      set { self.value.translatesAutoresizingMaskIntoConstraints = false }
    }

    public init(wrappedValue: T) {
      value = wrappedValue
    }
}

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


Description

  • Swift Tools 5.1.0
View More Packages from this Author

Dependencies

  • None
Last updated: Fri Oct 18 2024 21:02:09 GMT-0900 (Hawaii-Aleutian Daylight Time)