Giter Club home page Giter Club logo

yalta's Introduction

⛵️ Yalta

Yalta is an intuitive and powerful Auto Layout library. Designed to be simple and safe, Yalta is perfect for both new and seasoned developers.

The entire library fits in just two files (core + extensions) with less than 250 lines of code which you can just drag-n-drop into your app.

Yalta strives for clarity and simplicity by following Swift API Design Guidelines. Although most of the APIs are compact, it is a non-goal to enable the most concise syntax possible. Instead, Yalta has a fluent API that makes use sites form grammatical English phrases - that's what makes Swift code really stand out.

Anchors

In Yalta, you start by selecting an anchor or a collection of anchors of a view (or a layout guide). Then use anchor's methods to create constraints.

Anchors represent layout attributes of a view including edges, dimensions, axis and baselines.

The best way to access anchors is by using a special addSubview(_:constraints:) method (supports up to 4 views). Here are some examples of what you can do using anchors:

view.addSubview(subview) {
    $0.edges.pinToSuperview() // Pins the edges to fill the superview
    $0.edges.pinToSuperview(insets: Insets(10)) // With insets
    $0.edges.pinToSuperviewMargins() // Or margins

    $0.edges(.left, .right).pinToSuperview() // Fill along horizontal axis
    $0.centerY.alignWithSuperview() // Center along vertical axis
}

With addSubview(_:constraints:) method you define a view hierarchy and layout views at the same time. It encourages splitting layout code into logical blocks and prevents some programmer errors (e.g. trying to add constraints to views not in view hierarchy).

Each anchor and collection of anchors have methods which make sense for that particular kind of anchor:

view.addSubview(title, subtitle) { title, subtitle in
    subtitle.top.align(with: title.bottom + 10)

    title.centerX.alignWithSuperview()

    title.width.set(100)
    subtitle.width.match(title.width + 20)

    // You can change a priority of constraints inside a group:
    subtitle.bottom.pinToSuperview().priority = UILayoutPriority(999)
}

All anchors are also accessible via .al proxy:

title.al.top.pinToSuperview()

Yalta has full test coverage. If you'd like to learn about which constraints (NSLayoutConstraint) Yalta creates each time you call one of its methods, test cases are a great place to start.

Why Yalta

Yalta is for someone who:

Yalta is a beautiful port city on the Black Sea, and a great name for yet another layout tool with anchors.

yalta's People

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.