Skip to content

wzxha/Viscosity

Repository files navigation

Viscosity

swift version travis-ci Platform Cocoapods Compatible
Autolayout DSL for iOS
Simple and Powerful.

Usage

Normal

 view.vis.makeConstraints { make in
   make.left == view.vis.right *~ 2 +~ 100 ~~ .low ~| true
 }
 view.vis.makeConstraints { make in
   make.size <= 100 ~~ .low
 }
 view.vis.makeConstraints { make in
   make[.left, .right, .top] == view
   make[.width, .height] == [100, 100] 
   // equal to `make[.width, .height] == 100`
   // not equal to `make[.width, .height] == [100]`
 }

Update

 view.vis.updateConstraints { make in }

Remake

 view.vis.remakeConstraints { make in }

Operator

Operator Position Description
== mid equal
>= mid greaterThanOrEqual
<= mid lessThanOrEqual
+~ mid offset
*~ mid multiplier
~~ mid priority
~| mid isActive

Installation

Swift Package Manager

Package.swift

let package = Package(
    name: "XXX",
    dependencies: [
        .Package(url: "https://github.com/Wzxhaha/Viscosity", majorVersion: 2)
    ]
)

CocoaPods

CocoaPods is a dependency manager for Cocoa projects. You can install it with the following command:

$ gem install cocoapods

To integrate Viscosity into your Xcode project using CocoaPods, specify it in your Podfile:

# Uncomment the next line to define a global platform for your project
# platform :ios, '9.0'

target '<Your Target Name>' do
  # Comment the next line if you're not using Swift and don't want to use dynamic frameworks
  use_frameworks!
  pod 'Viscosity', '~> 2.0'

end

Then, run the following command:

$ pod install

Manually

Of course, you can manually integrate it into your project.

License

Viscosity is released under the MIT license. See LICENSE for details.

About

Autolayout DSL for iOS

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 2

  •  
  •