Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

🍃 Concise Autolayout code

License

NotificationsYou must be signed in to change notification settings

freshOS/Stevia

Repository files navigation

Stevia

DocumentationLanguage: Swift 2, 3, 4, 5 and 6Platform: iOS 8+SwiftBuild Statuscodebeat badgeLicense: MITGitHub contributorsGitHub tag

Drawing

Winner of Hacking with Swift Recommended award

You + Stevia = 🦄

  • 💡 Writeconcise,readable layouts
  • 🏖Reduce yourmaintenance time
  • 🎨Compose your styles,CSS-like
  • 🔴 PlugLive reload andboost your iteration cycles

Reason -Example -Live Reload -Installation -Documentation

🖼 Visual Layout Api

layout{100|-email-|~8010%|-password-forgot-|~80>=20    |login|~800}

⛓ 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==100password.CenterY== forgot.CenterYlogin.Top>= password.Bottom+20login.Width==75% Width(image.Height==100).priority=UILayoutPriority(rawValue:999)

All Generatenative NSLayoutConstraints 🎉

👨‍🔬Try it!

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

💡 Reason

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

How

By creating a tool that makes Auto layout code finallyreadable by a human being.
By coupling it with live code injection such asinjectionForXcode we candesign views in real time
View layout becomesfun,concise,maintainable and dare I say,beautiful ❤️

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, thenumber of characters goes from 2380 to 1239( ~ divided by 2)

WriteHalf the code that is actually10X more expressive and maintainable !

🔴 Live Reload

Live reload enables you to develop your views live without relaunching the app everytime.

Stevia +InjectionForXcode = #WhoNeedsReactNative?? 🚀

JustCmd+S and you can dev live in the simulator !

Learn more about how to set up live reloadhere.

⚙️ Installation

Stevia is installed via the officialSwift Package Manager.

SelectXcode>File>Swift Packages>Add Package Dependency...
and addhttps://github.com/freshOS/Stevia.

The Swift Package Manager (SPM) is now the official way to installstevia. The other package managers are now deprecated as of4.8.0 and won't be supported in future versions.
For Carthage/Cocoapods support (legacy versions) see documentationhere.

📖 Documentation

The following will teach you the gist of Stevia in one minute.
To go further, you can refer to the full documentationhere.

Stevia enables you to write readable Auto Layout code. It does so by tackling the 3 main components of layout:view hierarchy,layout andstyling.

01 - View hierarchy

email.translatesAutoresizingMaskIntoConstraints=falsepassword.translatesAutoresizingMaskIntoConstraints=falselogin.translatesAutoresizingMaskIntoConstraints=falseaddSubview(email)addSubview(password)addSubview(login)

becomes

subviews{    email    password    login}

02 - Layout

email.topAnchor.constraint(equalTo: topAnchor, constant:100).isActive=trueemail.leftAnchor.constraint(equalTo: leftAnchor, constant:8).isActive=trueemail.rightAnchor.constraint(equalTo: rightAnchor, constant:-8).isActive=trueemail.heightAnchor.constraint(equalToConstant:80).isActive=truepassword.topAnchor.constraint(equalTo: email.bottomAnchor, constant:8).isActive=truepassword.leftAnchor.constraint(equalTo: leftAnchor, constant:8).isActive=truepassword.rightAnchor.constraint(equalTo: rightAnchor, constant:-8).isActive=truepassword.heightAnchor.constraint(equalToConstant:80).isActive=truelogin.topAnchor.constraint(lessThanOrEqualTo: password.bottomAnchor, constant:20).isActive=truelogin.leftAnchor.constraint(equalTo: leftAnchor).isActive=truelogin.rightAnchor.constraint(equalTo: rightAnchor).isActive=truelogin.heightAnchor.constraint(equalToConstant:80).isActive=truelogin.bottomAnchor.constraint(equalTo: bottomAnchor, constant:0).isActive=true

becomes

layout{100|-email-|~808|-password-|~80>=20    |login|~800}

03 - Styling

email.borderStyle=.roundedRectemail.autocorrectionType=.noemail.keyboardType=.emailAddressemail.font=UIFont(name:"HelveticaNeue-Light", size:26)

becomes

email.style{ fin    f.borderStyle=.roundedRect    f.autocorrectionType=.no    f.keyboardType=.emailAddress    f.font=UIFont(name:"HelveticaNeue-Light", size:26)    f.returnKeyType=.next}

👨‍💻 Contributors

YannickDot,S4cha,Damien,Snowcraft,Mathieu-o,Blaz Merela,Theophane Rupin,Jason Liang,liberty4me,Scott Bates,Sai,Mike Gallagher,WaterNotWords,Mick MacCallum,Onur Genes

👥 Backers

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

📲 Apps using Stevia

Many top-notch Apps with millions of users use Stevia to write better Auto Layout code:

You are using Stevia ? Please let me know @sachadso@gmail.com and I'll add you to the list 😍!

🏅 Sponsors

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

Swift Version

Sponsor this project

  •  

Packages

No packages published

Contributors27


[8]ページ先頭

©2009-2026 Movatter.jp