Write concise Autolayout code

Overview

Stevia

Documentation Language: Swift 2, 3, 4 and 5 Platform: iOS 8+ Carthage compatible CocoaPods compatible Swift Build Status codebeat badge License: MIT GitHub contributors GitHub tag

Drawing

Winner of Hacking with Swift Recommended award

You + Stevia = πŸ¦„

  • πŸ’‘ Write concise, readable layouts
  • πŸ– Reduce your maintenance time
  • 🎨 Compose your styles, CSS-like
  • πŸ”΄ Plug Live reload and boost your iteration cycles

Reason - Example - Live Reload - Installation - Documentation

πŸ–Ό Visual Layout Api

layout {
    100
    |-email-| ~ 80
    10%
    |-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
(image.Height == 100).priority = UILayoutPriority(rawValue: 999)

All Generate native NSLayoutConstraints πŸŽ‰

πŸ‘¨β€πŸ”¬ Try it!

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

πŸ’‘ Reason

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 ❀️

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 !

πŸ”΄ Live Reload

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

Stevia + InjectionForXcode = #WhoNeedsReactNative?? πŸš€

Just Cmd+S and you can dev live in the simulator !

Learn more about how to set up live reload here.

βš™οΈ Installation

Stevia is installed via the official Swift Package Manager.

Select Xcode>File> Swift Packages>Add Package Dependency...
and add https://github.com/freshOS/Stevia.

The Swift Package Manager (SPM) is now the official way to install stevia. The other package managers are now deprecated as of 4.8.0 and won't be supported in future versions.
For Carthage/Cocoapods support (legacy versions) see documentation here.

πŸ“– Documentation

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

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

01 - View hierarchy

email.translatesAutoresizingMaskIntoConstraints = false
password.translatesAutoresizingMaskIntoConstraints = false
login.translatesAutoresizingMaskIntoConstraints = false
addSubview(email)
addSubview(password)
addSubview(login)

becomes

subviews {
    email
    password
    login
}

02 - Layout

email.topAnchor.constraint(equalTo: topAnchor, constant: 100).isActive = true
email.leftAnchor.constraint(equalTo: leftAnchor, constant: 8).isActive = true
email.rightAnchor.constraint(equalTo: rightAnchor, constant: -8).isActive = true
email.heightAnchor.constraint(equalToConstant: 80).isActive = true

password.topAnchor.constraint(equalTo: email.bottomAnchor, constant: 8).isActive = true
password.leftAnchor.constraint(equalTo: leftAnchor, constant: 8).isActive = true
password.rightAnchor.constraint(equalTo: rightAnchor, constant: -8).isActive = true
password.heightAnchor.constraint(equalToConstant: 80).isActive = true

login.topAnchor.constraint(lessThanOrEqualTo: password.bottomAnchor, constant: 20).isActive = true
login.leftAnchor.constraint(equalTo: leftAnchor).isActive = true
login.rightAnchor.constraint(equalTo: rightAnchor).isActive = true
login.heightAnchor.constraint(equalToConstant: 80).isActive = true
login.bottomAnchor.constraint(equalTo: bottomAnchor, constant: 0).isActive = true

becomes

layout {
    100
    |-email-| ~ 80
    8
    |-password-| ~ 80
    >=20
    |login| ~ 80
    0
}

03 - Styling

email.borderStyle = .roundedRect
email.autocorrectionType = .no
email.keyboardType = .emailAddress
email.font = UIFont(name: "HelveticaNeue-Light", size: 26)

becomes

email.style { f in
    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 @[email protected] 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

Comments
  • Leading and Trailing Constraint

    Leading and Trailing Constraint

    Hi, I saw your Library, and it is awe-inspiring. I tried, but I didn't find leading and trailing constraint for chainable API. Is this API support for these constraints? If yes then where to find it?

    opened by rehannali 24
  • Combine Stevia with Material Design

    Combine Stevia with Material Design

    Hi,

    I try to combine Stevia with Material Design, i just edit Stevia example end join with Material, but i can't modify style UITextField to TextField Material, how to config Material and Stevia?

    opened by arimunandar 18
  • After Layout, how to change the value of one NSLayoutConstraint constant

    After Layout, how to change the value of one NSLayoutConstraint constant

    After Layout, how to change the value of one NSLayoutConstraint constant。 Your code is greater and conciser. I like it. But if I make a animation ,How to change the value of one layoutConstraint?

    I want to insert juedge code here, it`s OK?

    public func constraint(item view1: AnyObject,
        attribute attr1: NSLayoutAttribute,
        relatedBy: NSLayoutRelation = .Equal,
        toItem view2: AnyObject? = nil,
        attribute attr2: NSLayoutAttribute? = nil, // Not an attribute??
        multiplier: CGFloat = 1,
        constant: CGFloat = 0) -> NSLayoutConstraint {
        let constraint = New NSLayoutConstraint
        if old constraint is exist {
            remove old constraint
        }
        add constraint.
    }
    
    opened by huang1988519 14
  • XCode 10 GM and Swift 4.2 fails to build

    XCode 10 GM and Swift 4.2 fails to build

    /Users/joelaws/Workspace/kratos/Pods/SteviaLayout/Source/Stevia+Fill.swift:58:35: 'UILayoutConstraintAxis' has been renamed to 'NSLayoutConstraint.Axis'
    /Users/joelaws/Workspace/kratos/Pods/UIKit.UILayoutConstraintAxis:2:18: 'UILayoutConstraintAxis' was obsoleted in Swift 4.2
    /Users/joelaws/Workspace/kratos/Pods/SteviaLayout/Source/Stevia+Fill.swift:59:16: 'NSLayoutAttribute' has been renamed to 'NSLayoutConstraint.Attribute'
    /Users/joelaws/Workspace/kratos/Pods/UIKit.NSLayoutAttribute:2:18: 'NSLayoutAttribute' was obsoleted in Swift 4.2
    /Users/joelaws/Workspace/kratos/Pods/SteviaLayout/Source/Stevia+Fill.swift:60:16: 'NSLayoutAttribute' has been renamed to 'NSLayoutConstraint.Attribute'
    /Users/joelaws/Workspace/kratos/Pods/UIKit.NSLayoutAttribute:2:18: 'NSLayoutAttribute' was obsoleted in Swift 4.2
    /Users/joelaws/Workspace/kratos/Pods/SteviaLayout/Source/Stevia+Constraints.swift:112:41: 'NSLayoutAttribute' has been renamed to 'NSLayoutConstraint.Attribute'
    /Users/joelaws/Workspace/kratos/Pods/UIKit.NSLayoutAttribute:2:18: 'NSLayoutAttribute' was obsoleted in Swift 4.2
    /Users/joelaws/Workspace/kratos/Pods/SteviaLayout/Source/Stevia+Constraints.swift:113:35: 'NSLayoutRelation' has been renamed to 'NSLayoutConstraint.Relation'
    /Users/joelaws/Workspace/kratos/Pods/UIKit.NSLayoutRelation:2:18: 'NSLayoutRelation' was obsoleted in Swift 4.2
    /Users/joelaws/Workspace/kratos/Pods/SteviaLayout/Source/Stevia+Constraints.swift:115:41: 'NSLayoutAttribute' has been renamed to 'NSLayoutConstraint.Attribute'
    /Users/joelaws/Workspace/kratos/Pods/UIKit.NSLayoutAttribute:2:18: 'NSLayoutAttribute' was obsoleted in Swift 4.2
    /Users/joelaws/Workspace/kratos/Pods/SteviaLayout/Source/Stevia+Size.swift:119:40: 'NSLayoutAttribute' has been renamed to 'NSLayoutConstraint.Attribute'
    /Users/joelaws/Workspace/kratos/Pods/UIKit.NSLayoutAttribute:2:18: 'NSLayoutAttribute' was obsoleted in Swift 4.2
    /Users/joelaws/Workspace/kratos/Pods/SteviaLayout/Source/Stevia+Size.swift:120:38: 'NSLayoutRelation' has been renamed to 'NSLayoutConstraint.Relation'
    /Users/joelaws/Workspace/kratos/Pods/UIKit.NSLayoutRelation:2:18: 'NSLayoutRelation' was obsoleted in Swift 4.2
    /Users/joelaws/Workspace/kratos/Pods/SteviaLayout/Source/Stevia+Size.swift:269:33: 'NSLayoutAttribute' has been renamed to 'NSLayoutConstraint.Attribute'
    /Users/joelaws/Workspace/kratos/Pods/UIKit.NSLayoutAttribute:2:18: 'NSLayoutAttribute' was obsoleted in Swift 4.2
    /Users/joelaws/Workspace/kratos/Pods/SteviaLayout/Source/Stevia+FlexibleMargin.swift:25:19: 'NSLayoutRelation' has been renamed to 'NSLayoutConstraint.Relation'
    /Users/joelaws/Workspace/kratos/Pods/UIKit.NSLayoutRelation:2:18: 'NSLayoutRelation' was obsoleted in Swift 4.2
    /Users/joelaws/Workspace/kratos/Pods/SteviaLayout/Source/Stevia+Constraints.swift:79:48: 'NSLayoutAttribute' has been renamed to 'NSLayoutConstraint.Attribute'
    /Users/joelaws/Workspace/kratos/Pods/UIKit.NSLayoutAttribute:2:18: 'NSLayoutAttribute' was obsoleted in Swift 4.2
    /Users/joelaws/Workspace/kratos/Pods/SteviaLayout/Source/Stevia+Constraints.swift:80:42: 'NSLayoutRelation' has been renamed to 'NSLayoutConstraint.Relation'
    /Users/joelaws/Workspace/kratos/Pods/UIKit.NSLayoutRelation:2:18: 'NSLayoutRelation' was obsoleted in Swift 4.2
    /Users/joelaws/Workspace/kratos/Pods/SteviaLayout/Source/Stevia+Constraints.swift:82:48: 'NSLayoutAttribute' has been renamed to 'NSLayoutConstraint.Attribute'
    /Users/joelaws/Workspace/kratos/Pods/UIKit.NSLayoutAttribute:2:18: 'NSLayoutAttribute' was obsoleted in Swift 4.2
    /Users/joelaws/Workspace/kratos/Pods/SteviaLayout/Source/Stevia+Size.swift:214:5: Type of expression is ambiguous without more context
    /Users/joelaws/Workspace/kratos/Pods/SteviaLayout/Source/Stevia+Size.swift:221:5: Type of expression is ambiguous without more context
    /Users/joelaws/Workspace/kratos/Pods/SteviaLayout/Source/Stevia+Size.swift:258:5: Type of expression is ambiguous without more context
    /Users/joelaws/Workspace/kratos/Pods/SteviaLayout/Source/Stevia+Size.swift:265:5: Type of expression is ambiguous without more context
    /Users/joelaws/Workspace/kratos/Pods/SteviaLayout/Source/Stevia+GetConstraint.swift:142:48: 'NSLayoutAttribute' has been renamed to 'NSLayoutConstraint.Attribute'
    /Users/joelaws/Workspace/kratos/Pods/UIKit.NSLayoutAttribute:2:18: 'NSLayoutAttribute' was obsoleted in Swift 4.2
    /Users/joelaws/Workspace/kratos/Pods/SteviaLayout/Source/Stevia+Position.swift:159:43: 'NSLayoutAttribute' has been renamed to 'NSLayoutConstraint.Attribute'
    /Users/joelaws/Workspace/kratos/Pods/UIKit.NSLayoutAttribute:2:18: 'NSLayoutAttribute' was obsoleted in Swift 4.2
    /Users/joelaws/Workspace/kratos/Pods/SteviaLayout/Source/Stevia+Position.swift:160:42: 'NSLayoutRelation' has been renamed to 'NSLayoutConstraint.Relation'
    /Users/joelaws/Workspace/kratos/Pods/UIKit.NSLayoutRelation:2:18: 'NSLayoutRelation' was obsoleted in Swift 4.2
    /Users/joelaws/Workspace/kratos/Pods/SteviaLayout/Source/Stevia+Equation.swift:13:20: 'NSLayoutAttribute' has been renamed to 'NSLayoutConstraint.Attribute'
    /Users/joelaws/Workspace/kratos/Pods/UIKit.NSLayoutAttribute:2:18: 'NSLayoutAttribute' was obsoleted in Swift 4.2
    /Users/joelaws/Workspace/kratos/Pods/SteviaLayout/Source/Stevia+FlexibleMargin.swift:14:41: Argument passed to call that takes no arguments
    /Users/joelaws/Workspace/kratos/Pods/SteviaLayout/Source/Stevia+FlexibleMargin.swift:20:41: Argument passed to call that takes no arguments
    /Users/joelaws/Workspace/kratos/Pods/SteviaLayout/Source/Stevia+Alignment.swift:139:28: 'UILayoutConstraintAxis' has been renamed to 'NSLayoutConstraint.Axis'
    /Users/joelaws/Workspace/kratos/Pods/UIKit.UILayoutConstraintAxis:2:18: 'UILayoutConstraintAxis' was obsoleted in Swift 4.2
    /Users/joelaws/Workspace/kratos/Pods/SteviaLayout/Source/Stevia+Alignment.swift:150:28: 'UILayoutConstraintAxis' has been renamed to 'NSLayoutConstraint.Axis'
    /Users/joelaws/Workspace/kratos/Pods/UIKit.UILayoutConstraintAxis:2:18: 'UILayoutConstraintAxis' was obsoleted in Swift 4.2
    /Users/joelaws/Workspace/kratos/Pods/SteviaLayout/Source/Stevia+Alignment.swift:357:32: 'NSLayoutAttribute' has been renamed to 'NSLayoutConstraint.Attribute'
    /Users/joelaws/Workspace/kratos/Pods/UIKit.NSLayoutAttribute:2:18: 'NSLayoutAttribute' was obsoleted in Swift 4.2
    /Users/joelaws/Workspace/kratos/Pods/SteviaLayout/Source/Stevia+Alignment.swift:54:5: Type of expression is ambiguous without more context
    /Users/joelaws/Workspace/kratos/Pods/SteviaLayout/Source/Stevia+Alignment.swift:61:5: Type of expression is ambiguous without more context
    /Users/joelaws/Workspace/kratos/Pods/SteviaLayout/Source/Stevia+Alignment.swift:95:5: Type of expression is ambiguous without more context
    /Users/joelaws/Workspace/kratos/Pods/SteviaLayout/Source/Stevia+Alignment.swift:100:5: Type of expression is ambiguous without more context
    /Users/joelaws/Workspace/kratos/Pods/SteviaLayout/Source/Stevia+Alignment.swift:124:5: Type of expression is ambiguous without more context
    /Users/joelaws/Workspace/kratos/Pods/SteviaLayout/Source/Stevia+Alignment.swift:136:5: Type of expression is ambiguous without more context
    /Users/joelaws/Workspace/kratos/Pods/SteviaLayout/Source/Stevia+Alignment.swift:152:21: 'NSLayoutAttribute' has been renamed to 'NSLayoutConstraint.Attribute'
    /Users/joelaws/Workspace/kratos/Pods/UIKit.NSLayoutAttribute:2:18: 'NSLayoutAttribute' was obsoleted in Swift 4.2
    /Users/joelaws/Workspace/kratos/Pods/SteviaLayout/Source/Stevia+Alignment.swift:203:5: Type of expression is ambiguous without more context
    /Users/joelaws/Workspace/kratos/Pods/SteviaLayout/Source/Stevia+Alignment.swift:210:5: Type of expression is ambiguous without more context
    /Users/joelaws/Workspace/kratos/Pods/SteviaLayout/Source/Stevia+Alignment.swift:257:5: Type of expression is ambiguous without more context
    /Users/joelaws/Workspace/kratos/Pods/SteviaLayout/Source/Stevia+Alignment.swift:264:5: Type of expression is ambiguous without more context
    /Users/joelaws/Workspace/kratos/Pods/SteviaLayout/Source/Stevia+Alignment.swift:301:5: Type of expression is ambiguous without more context
    /Users/joelaws/Workspace/kratos/Pods/SteviaLayout/Source/Stevia+Alignment.swift:308:5: Type of expression is ambiguous without more context
    /Users/joelaws/Workspace/kratos/Pods/SteviaLayout/Source/Stevia+Alignment.swift:345:5: Type of expression is ambiguous without more context
    /Users/joelaws/Workspace/kratos/Pods/SteviaLayout/Source/Stevia+Alignment.swift:352:5: Type of expression is ambiguous without more context
    /Users/joelaws/Workspace/kratos/Pods/SteviaLayout/Source/Stevia+Stacks.swift:181:36: 'UILayoutConstraintAxis' has been renamed to 'NSLayoutConstraint.Axis'
    /Users/joelaws/Workspace/kratos/Pods/UIKit.UILayoutConstraintAxis:2:18: 'UILayoutConstraintAxis' was obsoleted in Swift 4.2
    /Users/joelaws/Workspace/kratos/Pods/SteviaLayout/Source/Stevia+Stacks.swift:183:16: 'NSLayoutAttribute' has been renamed to 'NSLayoutConstraint.Attribute'
    /Users/joelaws/Workspace/kratos/Pods/UIKit.NSLayoutAttribute:2:18: 'NSLayoutAttribute' was obsoleted in Swift 4.2
    /Users/joelaws/Workspace/kratos/Pods/SteviaLayout/Source/Stevia+Stacks.swift:184:16: 'NSLayoutAttribute' has been renamed to 'NSLayoutConstraint.Attribute'
    /Users/joelaws/Workspace/kratos/Pods/UIKit.NSLayoutAttribute:2:18: 'NSLayoutAttribute' was obsoleted in Swift 4.2
    /Users/joelaws/Workspace/kratos/Pods/SteviaLayout/Source/Stevia+Equation.swift:17:35: 'NSLayoutAttribute' has been renamed to 'NSLayoutConstraint.Attribute'
    /Users/joelaws/Workspace/kratos/Pods/UIKit.NSLayoutAttribute:2:18: 'NSLayoutAttribute' was obsoleted in Swift 4.2
    /Users/joelaws/Workspace/kratos/Pods/SteviaLayout/Source/Stevia+Equation.swift:24:35: 'NSLayoutAttribute' has been renamed to 'NSLayoutConstraint.Attribute'
    /Users/joelaws/Workspace/kratos/Pods/UIKit.NSLayoutAttribute:2:18: 'NSLayoutAttribute' was obsoleted in Swift 4.2
    /Users/joelaws/Workspace/kratos/Pods/SteviaLayout/Source/Stevia+Constraints.swift:40:36: 'NSLayoutAttribute' has been renamed to 'NSLayoutConstraint.Attribute'
    /Users/joelaws/Workspace/kratos/Pods/UIKit.NSLayoutAttribute:2:18: 'NSLayoutAttribute' was obsoleted in Swift 4.2
    /Users/joelaws/Workspace/kratos/Pods/SteviaLayout/Source/Stevia+Constraints.swift:41:30: 'NSLayoutRelation' has been renamed to 'NSLayoutConstraint.Relation'
    /Users/joelaws/Workspace/kratos/Pods/UIKit.NSLayoutRelation:2:18: 'NSLayoutRelation' was obsoleted in Swift 4.2
    /Users/joelaws/Workspace/kratos/Pods/SteviaLayout/Source/Stevia+Constraints.swift:43:36: 'NSLayoutAttribute' has been renamed to 'NSLayoutConstraint.Attribute'
    /Users/joelaws/Workspace/kratos/Pods/UIKit.NSLayoutAttribute:2:18: 'NSLayoutAttribute' was obsoleted in Swift 4.2
    
    opened by jlaws 9
  • Infer and apply view hierarchy based on layout configuration

    Infer and apply view hierarchy based on layout configuration

    It seems to be unnecessary to first manually create view hierarchy and then define auto layout configuration (using beautiful Stevia visual notation).

    opened by maximkhatskevich 9
  • How to align horizontal views bottom rather than center ?

    How to align horizontal views bottom rather than center ?

    layout(
          0,
          |view1.size(100)-4-view2.size(40)
    )
    

    view1: height = 100 view2: height = 40

    image

    I want to align view2.bottom to view1.bottom, how?

    opened by rayman-v 8
  • Why to delete function layout(objects: [Any])? It causes a serious problem.

    Why to delete function layout(objects: [Any])? It causes a serious problem.

    var array:[Any] = [0]
    for i in 1...10 {
        let view = UIView()
        array.append(view)
    }
    array.append(0)
    layout(array)
    

    array is inferred as Any rather than [Any] that causes layout error.

    opened by cp3hnu 8
  • Pin Left & Pin Right with Multiple Lines

    Pin Left & Pin Right with Multiple Lines

    For a uitableviewcell layout, how can you pin text to the left and text to the right with space in-between, but if the space in the text from the left will run into the text on the right, it will wrap to the next line.

    I want it to look as follows: screen shot 2017-04-06 at 2 36 01 pm

    I tried to implement this with the following code and other variations similar to it:

    class AppointmentCell: UITableViewCell {
    
        var name = UILabel()
        var time = UILabel()
    
        required init?(coder aDecoder: NSCoder) { super.init(coder: aDecoder)}
        override init(style: UITableViewCellStyle, reuseIdentifier: String?) {
            super.init(style: style, reuseIdentifier: reuseIdentifier)
    
            sv(
                name.style(nameStyle),
                time
            )
    
            alignHorizontally(|-name.centerVertically()-""-time.centerVertically()-|)
        }
    
        func nameStyle(l:UILabel) {
            l.numberOfLines = 0
            l.textColor = .blue
        }
    }
    
    opened by ghost 7
  • Layout [] issue.

    Layout [] issue.

    @s4cha This is going worse day by day. It's related to a #50

             layout(
                10,
                |-countryPhoneCodePicker-| ~ 300,
                10,
                |-phone-| ~ 80
            )
    

    View: screen shot 2016-07-28 at 1 30 50 pm

    This is prefect. But when I make it an Array.

            layout([
                10,
                |-countryPhoneCodePicker-| ~ 300,
                10,
                |-phone-| ~ 80
            ])
    

    View: screen shot 2016-07-28 at 1 32 06 pm

    opened by iraycd 7
  • Ho do I layout nested views (specifically inside UIScrollView)?

    Ho do I layout nested views (specifically inside UIScrollView)?

    Please give, an example. Samples provided in Readme are all about plain hierarchy. In particular, how do I layout views nested in a scroll view (when you implement a login screen, you typically put controls inside a scroll view to avoid keyboard overlapping with your controls). I tried few scenarios, but nested views are always positioned incorrectly (off screen).

    Please, help!

    opened by maximkhatskevich 7
  • Swift package Tests

    Swift package Tests

    This is needed to be able to pass Swift package tests since the package can be used for multiple platforms. If you're not using these tests, it is needed for every other Swift package which implements yours.

    opened by lukas-ruzicka 6
  • Different behaviour with same constraint

    Different behaviour with same constraint

    view.width(Device.width * 241 / 375) image

    view.widthAnchor.constraint(equalToConstant: Device.width * 241 / 375).isActive = true image

    with stevia the priority is 751, so the width is ambigous.

    opened by NikKovIos 0
  • Multiplier in Constraints

    Multiplier in Constraints

    Hi, how can we add multiplier to any constraint Example snapkit make.centerY.equalTo(self).multipliedBy(0.8)

    Example native: selectionView.centerXAnchor.constraint(equalTo: safeArea.centerXAnchor, multiplier: 0.8).isActive = true

    I don't found a way to add multiplier. It only have constant/padding to constraint.

    opened by rehannali 0
  • Support for cornerRadius

    Support for cornerRadius

    Being able to set cornerRadius(12) along with the rest of my Stevia layout code would really be nice.

    It would need to set layer.masksToBounds = false automatically, similar to how Stevia currently sets translatesAutoresizingMaskIntoConstraints = false.

    At the moment I have this added in Stevia fashion myself through

    extension UIView {
    	
    	func cornerRadius(_ radius: CGFloat) {
    		
    		layer.masksToBounds = true
    		layer.cornerRadius = radius
    	}
    }
    

    but it'd be nice to have cornerRadius supported.

    opened by PaulDoesDev 0
  • SwiftUI preview fails with error: could not find module 'Stevia' for target 'x86_64-apple-ios-simulator'; found: arm64-apple-ios-simulator

    SwiftUI preview fails with error: could not find module 'Stevia' for target 'x86_64-apple-ios-simulator'; found: arm64-apple-ios-simulator

    Can anyone help me with this error: could not find module 'Stevia' for target 'x86_64-apple-ios-simulator'; found: arm64-apple-ios-simulator

    This is coming when I'm trying SwiftUI previews. Code is compiling but somehow preview is throwing error.

    Screenshot 2022-06-16 at 6 56 17 PM
    opened by vaibhyKbk 0
  • using layout with safeAreaLayoutGuide

    using layout with safeAreaLayoutGuide

    I love the simplicity of layout but I keep finding areas where I seem to need to use other commands external to that block.

    for example, is there a simple say to include safeAreaLayoutGuide in the equations

    something like:

    layout( ~ |view1| |view2|
    ~ )

    for top and bottom constraints that are safe

    Similarly, what about centering horizontally and vertically in the layout, or distributing views within the available space (like a stack view)

    Am I missing something?

    opened by kallipigous 0
Releases(5.1.2)
Owner
Fresh
Simple iOS tools to solve problems 99% of us have.
Fresh
Powerful autolayout framework, that can manage UIView(NSView), CALayer and not rendered views. Not Apple Autolayout wrapper. Provides placeholders. Linux support.

CGLayout Powerful autolayout framework, that can manage UIView(NSView), CALayer and not rendered views. Has cross-hierarchy coordinate space. Implemen

Koryttsev Denis 45 Jun 28, 2022
Fast Swift Views layouting without auto layout. No magic, pure code, full control and blazing fast. Concise syntax, intuitive, readable & chainable. [iOS/macOS/tvOS/CALayer]

Extremely Fast views layouting without auto layout. No magic, pure code, full control and blazing fast. Concise syntax, intuitive, readable & chainabl

layoutBox 2.1k Dec 22, 2022
FlexLayout adds a nice Swift interface to the highly optimized facebook/yoga flexbox implementation. Concise, intuitive & chainable syntax.

FlexLayout adds a nice Swift interface to the highly optimized Yoga flexbox implementation. Concise, intuitive & chainable syntax. Flexbox is an incre

layoutBox 1.7k Dec 30, 2022
Concise Auto Layout API to chain programmatic constraints while easily updating existing constraints.

Concise API for Auto Layout. SnapLayout extends UIView and NSView to deliver a list of APIs to improve readability while also shortening constraint co

Satinder Singh 11 Dec 17, 2021
An easier and faster way to code Autolayout

EZAnchor 中文介绍 An easier way to code Autolayout Are you annoyed of coding .active = true while using Autolayout Anchors over and over again? Are you an

Alex.Liu 25 Feb 20, 2022
The fast path to autolayout views in code

NorthLayout The fast path to autolayout views in code Talks https://speakerdeck.com/banjun/auto-layout-with-an-extended-visual-format-language at AltC

banjun 36 Jul 15, 2022
An extension that simplifies the work with Swift AutoLayout by writing cleaner, more natural and easy-reading code.

Installation For now you're able to clone repo in your project or download ZIP folder manually. git clone https://github.com/votehserxam/AutoLayout.gi

Max 3 Nov 8, 2022
Write less UI code

Layoutless Layoutless enables you to spend less time writing UI code. It provides a way to declaratively style and layout views. Here is an example of

Declarative Hub 428 Oct 9, 2022
πŸ“±AutoLayout can be set differently for each device

DeviceLayout DeviceLayout is a Swift framework that lets you set Auto Layout constraints's differently for each device Using only IBInspector of Xcode

Cruz 171 Oct 11, 2022
A Swift Autolayout DSL for iOS & OS X

SnapKit is a DSL to make Auto Layout easy on both iOS and OS X. ⚠️ To use with Swift 4.x please ensure you are using >= 4.0.0 ⚠️ ⚠️ To use with Swift

null 19.1k Jan 2, 2023
πŸ— MondrianLayout - describing structured layout for AutoLayout

?? A DSL based layout builder for AutoLayout

Muukii 155 Dec 10, 2022
This "Calculator" application is a simple one screen design of calculator screen i have made this single screen design application just to practice AutoLayout concepts.

Calculator Layout This "Calculator" application is a simple one screen design of calculator screen i have made this single screen design application j

Chetan Parate 1 Oct 29, 2021
Harness the power of AutoLayout NSLayoutConstraints with a simplified, chainable and expressive syntax. Supports iOS and OSX Auto Layout

Masonry Masonry is still actively maintained, we are committed to fixing bugs and merging good quality PRs from the wider community. However if you're

null 18k Jan 5, 2023
A bit of steroids for AutoLayout, powered by Swift.

AutoLayoutPlus AutoLayoutPlus is a Swift library consisting in a set of extensions to help dealing with Auto Layout programatically. With AutoLayoutPl

Rui Costa 27 Jul 25, 2022
Tiny Swift DSL for Autolayout

SwiftAutoLayout SwiftAutoLayout is a tiny DSL for Autolayout intended to provide a more declarative way to express layout constraints. Here's a quick

Indragie Karunaratne 657 Sep 18, 2022
An autolayout library for the damn fine citizens of San Diego.

Anchorman Do you think autolayout has to be hard? Nah. NSLayoutAnchor is pretty neat! But it's still a bit tedious of an API. Try writing .translatesA

Joe Fabisevich 79 May 25, 2022
Minimal AutoLayout convenience layer. Program constraints succinctly.

MiniLayout Minimal AutoLayout convenience layer. Program constraints succinctly. Usage Put label over textField // using MiniLayout: view.constrain(la

Yonat Sharon 8 Jul 7, 2021
A AutoLayout Utility for iOS

QLayout is an Utility to make Auto Layout easy on iOS. Contents Requirements Installation Usage Credits License Requirements iOS 8.0+ Swift 3.0+ Insta

Jose Quintero 3 Nov 14, 2021
AutoLayout Micro DSL SPM from Chris Eidhof's article

EasyAutoLayout Intro EasyAutoLayout is a small framework built using the ideas presented in the article called Autolayout Micro DSL by Chris Eidhof. I

Alexandre Garrefa 0 Nov 28, 2021