Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/dimix/storyboardconstraint
A simple way to use programmatically Autolayout Constraint created in Storyboard.
https://github.com/dimix/storyboardconstraint
autolayout autolayout-constraints constraints swift swift-3
Last synced: 4 months ago
JSON representation
A simple way to use programmatically Autolayout Constraint created in Storyboard.
- Host: GitHub
- URL: https://github.com/dimix/storyboardconstraint
- Owner: dimix
- License: mit
- Created: 2017-02-18T13:22:17.000Z (about 8 years ago)
- Default Branch: master
- Last Pushed: 2019-04-04T14:57:37.000Z (almost 6 years ago)
- Last Synced: 2024-10-14T22:21:33.319Z (4 months ago)
- Topics: autolayout, autolayout-constraints, constraints, swift, swift-3
- Language: Swift
- Size: 1.86 MB
- Stars: 25
- Watchers: 3
- Forks: 3
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# StoryboardConstraint
A simple way to use programmatically Autolayout Constraint created in Storyboard.
## Features
- Predefined basic constraints: top, bottom, leading, trailing, height, width, centerX, centerY
- A complete method to find a specific constraint through the views#### Podfile
To integrate StoryboardConstraint into your Xcode project using CocoaPods, specify it in your `Podfile`:
```ruby
source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '9.0'target 'TargetName' do
use_frameworks!
pod 'StoryboardConstraint'
end
```Then, run the following command:
```bash
$ pod install
```## How to Use
#### 1. Add UIView+StoryboardConstraint.swift on your project
#### 2. Get the constraintsYou can get the constraint set in Storyboard like this:
```swift
customView.heightConstraint?.constant = 200
customView.topConstraint?.constant = 20
```You can also set a custom constraint identifier and get it like this:
```swift
view.constraint(withIdentifier: "customWidth", searchInSubviews: true)?.constant = 50
```If you want you can get all the constraints with a specified attribute like this:
```swift
view.constraints(withAttribute: .height)
```
This method returns all the constraints found ordered by priority.## Requirements
Current version is compatible with:
* Swift 5.0
* iOS 10 or later