Latest 0.3.9
Homepage https://github.com/hooliooo/Alacrity
License MIT
Platforms ios 9.3
Frameworks UIKit
Authors

Alacrity is a library that brings a fluent interface for UIView and its subclasses.

CI Status
Version
License
Platform

Example

When writing UI code programmatically we would typically write code such as this:

class YourCustomView: UIView {
    let aView: UIView = UIView()
    let aLabel: UILabel = UILabel()

    func setUpUI() {
        // Customize aView
        aView.backgroundColor = UIColor.red
        aView.layer.cornerRadius = 5.0
        aView.clipToBounds = true

        // Customize aLabel
        aLabel.text = "Your text"
        aLabel.font = UIFont.boldSystemFont(ofSize: 19.0)
        aLabel.textAlignment = .center
        aLabel.backgroundColor = .orange
    }
}

or

class YourCustomView: UIView {
    let aView: UIView = {
        let view: UIView = UIView()
        view.backgroundColor = UIColor.red
        view.layer.cornerRadius = 5.0
        view.clipToBounds = true
        return view
    }()

    let aLabel: UILabel = {
        let label: UILabel = UILabel()
        label.text = "Your text"
        label.font = UIFont.boldSystemFont(ofSize: 19.0)
        label.textAlignment = .center
        label.backgroundColor = .orange
        return label
    }()
}

With Alacrity we can write something more succinct, without the boilerplate of typical programmatic UI code by taking advantage of its fluent interface

class YourCustomView: UIView {
    let aView: UIView = UIView().avd
        .backgroundColor(UIColor.red)
        .cornerRadius(5.0)
        .view

    let aLabel: UILabel = UILabel().acy
        .text("Your text")
        .font(UIFont.boldSystemFont(ofSize: 19.0))
        .textAlignment(.center)
        .backgroundColor(.orange)
        .view

}

Requirements

Alacrity requires iOS 10.0 or higher and Swift 3.x

Installation

  1. Add the following to your Podfile:
pod 'Alacrity'
  1. Integrate your dependencies using frameworks: add use_frameworks! to your Podfile.
  2. Run pod install.

Author

Julio Alorro

License

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

Latest podspec

{
    "name": "Alacrity",
    "version": "0.3.9",
    "summary": "Fluent interface approach to modifying UIViews",
    "homepage": "https://github.com/hooliooo/Alacrity",
    "license": {
        "type": "MIT",
        "file": "LICENSE"
    },
    "authors": {
        "Julio Alorro": "[email protected]"
    },
    "source": {
        "git": "https://github.com/hooliooo/Alacrity.git",
        "tag": "0.3.9"
    },
    "platforms": {
        "ios": "9.3"
    },
    "source_files": "Sources/**/*.swift",
    "frameworks": "UIKit",
    "swift_version": "4.2"
}

Pin It on Pinterest

Share This