Latest 0.2.5
Homepage https://github.com/e2technologies/UIBuilder-swift
License MIT
Platforms ios 8.0
Authors

[![CI Status](https://img.shields.io/travis/Eric Chapman/UIBuilder.svg?style=flat)](https://travis-ci.org/Eric Chapman/UIBuilder)
Version
License
Platform

Example

To run the example project, clone the repo, and run pod install from the Example directory first.

Installation

UIBuilder is available through CocoaPods. To install
it, simply add the following line to your Podfile:

pod 'UIBuilder'

Usage

An example of using this library is shown below. Please see the documentation at the
wiki

Note that I don’t have any unit tests yet. Currently the supplied example is run to make sure all of the methods are
working properly.

import UIKit
import UIBuilder

class ViewController: UIViewController {

    override func viewDidLoad() {
        super.viewDidLoad()

        self.view.backgroundColor = UIColor.gray

        let stripeHeight: CGFloat = 20

        // Build the top side
        let blueSquare = UIView()
        blueSquare.backgroundColor = UIColor.blue
        let blueSquareElement = blueSquare.element.height(7*stripeHeight).width(7*stripeHeight).halign(.left).valign(.top)

        var tStripes = [UIBuilderElement]()
        for i in 0..<7 {
            let stripe = UIView()
            stripe.backgroundColor = (i % 2) == 0 ? UIColor.red : UIColor.white
            tStripes.append(stripe.element.height(stripeHeight))
        }

        let topRightStripes = UIBuilder.stack(vertical: tStripes)
        let topHStack = UIBuilder.stack(horizontal: [blueSquareElement, topRightStripes])

        // Build the bottom side
        var bStripes = [UIBuilderElement]()
        for i in 0..<7 {
            let stripe = UIView()
            stripe.backgroundColor = (i % 2) == 0 ? UIColor.white : UIColor.red
            bStripes.append(stripe.element.height(stripeHeight))
        }
        let bottomVStack = UIBuilder.stack(vertical: bStripes)

        // Combine the top and bottom
        let mainView = UIBuilder.stack(vertical: [topHStack, bottomVStack]).build()

        self.view.addSubview(mainView)
        self.view.constrain.leftEdges(mainView).build()
        self.view.constrain.rightEdges(mainView).build()
        self.view.constrain.topEdges(mainView).build()
    }
}

License

UIBuilder is available under the MIT license. See the LICENSE file for more info.

Latest podspec

{
    "name": "UIBuilder",
    "version": "0.2.5",
    "summary": "An iOS swift library intended to assist with programatically building complicated UI elements.",
    "description": "Provides low level constraint based building blocks to ease development of programatically generatednviews.  Also includes stacking views that aid in more complex view creation.",
    "homepage": "https://github.com/e2technologies/UIBuilder-swift",
    "license": {
        "type": "MIT",
        "file": "LICENSE"
    },
    "authors": {
        "Eric Chapman": "[email protected]"
    },
    "source": {
        "git": "https://github.com/e2technologies/UIBuilder-swift.git",
        "tag": "0.2.5"
    },
    "swift_version": "4.0",
    "platforms": {
        "ios": "8.0"
    },
    "source_files": "UIBuilder/Classes/**/*"
}

Pin It on Pinterest

Share This