https://github.com/dankinsoid/constraintsoperators
Convenient operators for creating constraints
https://github.com/dankinsoid/constraintsoperators
Last synced: 10 months ago
JSON representation
Convenient operators for creating constraints
- Host: GitHub
- URL: https://github.com/dankinsoid/constraintsoperators
- Owner: dankinsoid
- License: other
- Created: 2019-08-08T13:31:10.000Z (almost 7 years ago)
- Default Branch: master
- Last Pushed: 2022-10-04T10:57:42.000Z (over 3 years ago)
- Last Synced: 2025-08-05T18:00:37.989Z (11 months ago)
- Language: Swift
- Homepage:
- Size: 896 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# ConstraintsOperators
[](https://cocoapods.org/pods/ConstraintsOperators)
[](https://cocoapods.org/pods/ConstraintsOperators)
[](https://cocoapods.org/pods/ConstraintsOperators)
[](https://cocoapods.org/pods/ConstraintsOperators)
## Usage
Сreate constraints with simple expressions:
```swift
view1.ignoreAutoresizingMask()
view1.centerX =| view2.centerX + 10
view1.centerY =| 15
view1.width <=| 200
view1.width >=| 100
//or
view1.width =| 100...200
view1.height =| view2.height / 2 + 20
...
view.width =| 100
view.width =| 200 //automatically replaces previuos width constraint
...
view1.height.priority(.defaultLow) =| 0
...
view1.height.priority(900) =| 10
...
let constraint: NSLayoutConstraint = view1.height.deactivated =| 200
...
view1.height =| view1.superview
view1.centerX =| view2
...
[view1, view2].ignoreAutoresizingMask()
[view1, view2].height =| 200
view1[.centerX, .centerY] =| 0
view1.edges(.vertical) =| 0
...
Axis.vertical =| [10, view1, 0..., view2.fixed(200), 0...5, view3.centerY, 10]
...
view1.top =| view1.leading //compile error, you cannot combine incompatible attributes
```
Supported operators: `=|`, `<=|`, `>=|`
Every operator returns a `NSLayoutConstraint` instance with the `isActive` property set to `true`.
## Installation
ConstraintsOperators is available through [CocoaPods](https://cocoapods.org). To install
it, simply add the following line to your Podfile:
```ruby
pod 'ConstraintsOperators'
```
## Author
Voidilov, voidilov@gmail.com
## License
ConstraintsOperators is available under the MIT license. See the LICENSE file for more info.