Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/yonat/MiniLayout
Minimal AutoLayout convenience layer. Program constraints succinctly. ⚠️ Moved into https://github.com/yonat/SweeterSwift
https://github.com/yonat/MiniLayout
autolayout swift syntactic-sugar
Last synced: 8 days ago
JSON representation
Minimal AutoLayout convenience layer. Program constraints succinctly. ⚠️ Moved into https://github.com/yonat/SweeterSwift
- Host: GitHub
- URL: https://github.com/yonat/MiniLayout
- Owner: yonat
- License: mit
- Archived: true
- Created: 2016-02-20T08:03:30.000Z (almost 9 years ago)
- Default Branch: master
- Last Pushed: 2019-06-21T11:19:01.000Z (over 5 years ago)
- Last Synced: 2024-11-14T12:03:08.870Z (28 days ago)
- Topics: autolayout, swift, syntactic-sugar
- Language: Swift
- Homepage:
- Size: 43.9 KB
- Stars: 8
- Watchers: 3
- Forks: 4
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE.txt
Awesome Lists containing this project
- awesome-ios - MiniLayout - Minimal AutoLayout convenience layer. Program constraints succinctly. (Layout / Other Hardware)
- awesome-ios-star - MiniLayout - Minimal AutoLayout convenience layer. Program constraints succinctly. (Layout / Other Hardware)
README
# MiniLayout
Minimal AutoLayout convenience layer. Program constraints succinctly.
[![Swift Version][swift-image]][swift-url]
[![Build Status][travis-image]][travis-url]
[![License][license-image]][license-url]
[![CocoaPods Compatible](https://img.shields.io/cocoapods/v/MiniLayout.svg)](https://img.shields.io/cocoapods/v/MiniLayout.svg)
[![Platform](https://img.shields.io/cocoapods/p/MiniLayout.svg?style=flat)](http://cocoapods.org/pods/MiniLayout)
[![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg?style=flat-square)](http://makeapullrequest.com)## Usage
### Put label over textField
```swift
// using MiniLayout:
view.constrain(label, at: .leading, to: textField)
view.constrain(textField, at: .top, to: label, at: .bottom, diff: 8)
// without MiniLayout:
view.addConstraint( NSLayoutConstraint(item: label, attribute: .leading, relatedBy: .equal, toItem: textField, attribute: .leading, multiplier: 1, constant: 0) )
view.addConstraint( NSLayoutConstraint(item: textField, attribute: .top, relatedBy: .equal, toItem: label, attribute: .bottom, multiplier: 1, constant: 8) )
```### Add button at the center of view
```swift
// using MiniLayout:
view.addConstrainedSubview(button, constrain: .centerX, .centerY)
// without MiniLayout:
view.addSubview(button)
button.setTranslatesAutoresizingMaskIntoConstraints(false)
view.addConstraint( NSLayoutConstraint(item: button, attribute: .centerX, relatedBy: .equal, toItem: view, attribute: .centerX, multiplier: 1, constant: 0) )
view.addConstraint( NSLayoutConstraint(item: button, attribute: .centerY, relatedBy: .equal, toItem: view, attribute: .centerY, multiplier: 1, constant: 0) )
```### Add child view controller covering all but the bottom margin
```swift
// using MiniLayout:
addConstrainedChild(vc, constrain: .bottomMargin, .top, .left, .right)
// without MiniLayout:
addChild(vc)
view.addSubview(vc.view)
vc.view.setTranslatesAutoresizingMaskIntoConstraints(false)
view.addConstraint( NSLayoutConstraint(item: vc.view, attribute: .bottomMargin, relatedBy: .equal, toItem: view, attribute: .bottomMargin, multiplier: 1, constant: 0) )
view.addConstraint( NSLayoutConstraint(item: vc.view, attribute: .top, relatedBy: .equal, toItem: view, attribute: .top, multiplier: 1, constant: 0) )
view.addConstraint( NSLayoutConstraint(item: vc.view, attribute: .left, relatedBy: .equal, toItem: view, attribute: .left, multiplier: 1, constant: 0) )
view.addConstraint( NSLayoutConstraint(item: vc.view, attribute: .right, relatedBy: .equal, toItem: view, attribute: .right, multiplier: 1, constant: 0) )
vc.didMove(toParent: self)```
## Installation
Manually:
Add `MiniLayout.swift` to your project.
Using CocoaPods:
```ruby
pod 'MiniLayout'
```Legacy versions:
| Swift version | MiniLayout version |
| :---: | :---: |
| 4.0 (Xcode 9.4) | `pod 'MiniLayout', '~> 1.2.1'` |
| 3 | `pod 'MiniLayout', '~> 1.1.0'` |
| 2.3 | `pod 'MiniLayout', '~> 1.0.1'` |## Meta
[@yonatsharon](https://twitter.com/yonatsharon)
[https://github.com/yonat/MiniLayout](https://github.com/yonat/MiniLayout)
[swift-image]:https://img.shields.io/badge/swift-4.2-orange.svg
[swift-url]: https://swift.org/
[license-image]: https://img.shields.io/badge/License-MIT-blue.svg
[license-url]: LICENSE.txt
[travis-image]: https://img.shields.io/travis/dbader/node-datadog-metrics/master.svg?style=flat-square
[travis-url]: https://travis-ci.org/dbader/node-datadog-metrics
[codebeat-image]: https://codebeat.co/badges/c19b47ea-2f9d-45df-8458-b2d952fe9dad
[codebeat-url]: https://codebeat.co/projects/github-com-vsouza-awesomeios-com