Skip to content

Overview

Stevia

Language: Swift 2, 3 and 4 Platform: iOS 8+ Carthage compatible CocoaPods compatible Build Status Join the chat at https://gitter.im/s4cha/Stevia License: MIT Release version

Visual Layout Api

layout(
    100,
    |-email-| ~ 80,
    8,
    |-password-forgot-| ~ 80,
    >=20,
    |login| ~ 80,
    0
)

Chainable Api

email.top(100).left(8).right(8).width(200).height(44)
alignHorizontally(password, forgot)
image.fillContainer()
button.centerInContainer().size(50%)
equalWidths(email, password)
image.width(>=80)

Equation-Based Api

email.Top == 100
password.CenterY == forgot.CenterY
login.Top >= password.Bottom + 20
login.Width == 75 % Width

All Generate native NSLayoutConstraints 🎉

Try it!

Stevia is part of freshOS iOS toolset. Try it in an example App ! Download Starter Project

Reason

Why

Because nothing holds more truth than pure code 🤓
Xibs and storyboards are heavy, hard to maintain, hard to merge.
They split the view concept into 2 separate files making debugging a nightmare
There must be a better way

How

By creating a tool that makes Auto layout code finally readable by a human being.
By coupling it with live code injection such as injectionForXcode we can design views in real time
View layout becomes fun, concise, maintainable and dare I say, beautiful ❤️

What

  • [x] Pure Swift Auto Layout DSL.
  • [x] Simple: the apis are just NSLayoutConstraint shortcuts, pure UIKit code, no voodoo magic.

Advantages of Stevia

  • [x] Improves the readability of Auto Layout in code.
  • [x] Concise yet flexible apis.
  • [x] Type-Safe Visual Format language.
  • [x] Decribe Horizontal & vertical layout at the same time.
  • [x] Supports Live reload, for faster iteration cycles.
  • [x] Styling is more concise, reusable and can be composed.

Login View Example

In the project folder, you can find an example of a typical login view laid out in both native and Stevia for you to understand and compare the two approaches.

As a spoiler alert, the number of characters goes from 2380 to 1239 ( ~ divided by 2)

Write Half the code that is actually 10X more expressive and maintainable !

Contributors

YannickDot, S4cha, Damien, Snowcraft, Mathieu-o

Swift Version

Swift 2 -> version 2.3.0
Swift 3 -> version 3.2.0
Swift 4 -> version 4.0.0

Backers

Like the project? Offer coffee or support us with a monthly donation and help us continue our activities :)

Sponsors

Become a sponsor and get your logo on our README on Github with a link to your site :)