Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/yume190/layoutanchor
https://github.com/yume190/layoutanchor
Last synced: 11 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/yume190/layoutanchor
- Owner: yume190
- License: mit
- Created: 2017-11-16T06:01:15.000Z (about 7 years ago)
- Default Branch: master
- Last Pushed: 2018-09-26T09:15:58.000Z (over 6 years ago)
- Last Synced: 2024-12-18T06:22:37.973Z (about 1 month ago)
- Language: Swift
- Size: 237 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
LayoutAnchor
==========An autolayout anchor wrapper.
Add some extenstion to `UIView` and `UILayoutGuide`
- [Extensions](#extensions)
- [Usage](#usage)
- [Requirements](#requirements)
- [Installation](#installation)
- [CocoaPods](#cocoaPods)
- [Carthage](#carthage)## Extensions
``` swift
// UIView and UILayoutGuide
var leading : LayoutAnchor
var trailing : LayoutAnchor
var left : LayoutAnchor
var right : LayoutAnchor
var centerX : LayoutAnchorvar top : LayoutAnchor
var bottom : LayoutAnchor
var centerY : LayoutAnchorvar width : LayoutAnchor
var height : LayoutAnchor// UIView
var firstBaseline : LayoutAnchor
var lastBaseline : LayoutAnchor
```## Usage
``` swift
let v1 = UIView();v1.translatesAutoresizingMaskIntoConstraints = false
let v2 = UIView();v2.translatesAutoresizingMaskIntoConstraints = falselet constraints:[NSLayoutConstraint] = [
v1.leading == v2.leading + 10,
v1.trailing == v2.trailing + 10,
v1.safeAreaLayoutGuide.top == v2.top - 10,
v1.safeAreaLayoutGuide.bottom == v2.bottom - 10,
]
constraints.activate()(v1.bottom == v2.bottom - 10).activate()
```## Requirements
- iOS 9.0+
- Xcode 9.0+
- Swift 4.0+## Installation
### CocoaPods
[CocoaPods](http://cocoapods.org) is a dependency manager for Cocoa projects. You can install it with the following command:
```bash
$ gem install cocoapods
```> CocoaPods 1.1+ is required to build Alamofire 4.0+.
To integrate LayoutAnchor into your Xcode project using CocoaPods, specify it in your `Podfile`:
```ruby
source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '9.0'
use_frameworks!target '' do
pod 'LayoutAnchor', '~> 4.0'
end
```Then, run the following command:
```bash
$ pod install
```### Carthage
[Carthage](https://github.com/Carthage/Carthage) is a decentralized dependency manager that builds your dependencies and provides you with binary frameworks.
You can install Carthage with [Homebrew](http://brew.sh/) using the following command:
```bash
$ brew update
$ brew install carthage
```To integrate LayoutAnchor into your Xcode project using Carthage, specify it in your `Cartfile`:
```ogdl
github "yume190/LayoutAnchor" ~> 4.0
```Run `carthage update --platform ios` to build the framework and drag the built LayoutAnchor.framework into your Xcode project.