Git Product home page Git Product logo

alhelper's Introduction

Build

ALHelper

A simple and lightweight library that adds a few convenience methods when using AutoLayout to construct your views.

Installation

Available via Swift Package Manager (SPM) or via Cocoapods

SPM

In Xcode, go to File > Add Package, in the upper right hand corner paste the URL to this Github page: https://github.com/ChadGarrett/ALHelper and click on add package.

Cocoapods

Simply add the pod to your Podfile and run pod install.

pod 'ALHelper'

Requirements

  • Swift 5+

  • iOS 11+

Usage

As this library was only a test for setting up Cocoapods + SPM packages, it only includes two very simple (but tested!) helpers at the moment.

You can use addSubviewAndPinToSuperviewEdges(insets:UIEdgeInsets) to add a view to a parent view, and pin its top, leading, trailing and bottom edges to the parents edges with the optionally supplied insets.

Alternatively, you can use pinToSuperviewEdges directly on a child view if it has already been added to a parent to simply add the constraints and optionally supplied insets.

Examples

addSubviewAndPinToSuperviewEdges

    let parentView = UIView()
    let childView = UIView()
    let insets = UIEdgeInsets(top: 5)

    parentView.addSubviewAndPinToSuperviewEdges(childView, insets: insets)

pinToSuperviewEdges

    let parentView = UIView()
    let childView = UIView()
    parentView.addSubview(childView)
    childView.pinToSuperviewEdges()

alhelper's People

Contributors

chadgarrett avatar

Stargazers

Narcis avatar

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.