Latest 0.6.0
Homepage https://github.com/respan/ChainableSwift
License MIT
Platforms ios 8.0
Authors

ChainableSwift 🔗

Version
License
Platform

Work in progress 🙄

Why?

Because you can write this:

let label = UILabel()
                .text("My awesome title")
                .textColor(.white)
                .backgroundColor(.black)
                .textAlignment(.center)
                .font(.boldSystemFont(ofSize: 17))
                .layerCornerRadius(2)
                .clipsToBounds(true)

instead of this:

let label = UILabel()

label.text = "My awesome title"
label.textColor = .white
label.backgroundColor = .black
label.textAlignment = .center
label.font = .boldSystemFont(ofSize: 17)
label.layer.cornerRadius = 2
label.clipsToBounds = true

The awesome thing is, you can thin your viewDidLoad or init methods:

class MyIntroView: UIView {
    let coverView = UIView().backgroundColor(.red)

    let titleLabel = UILabel().font(.boldSystemFont(ofSize: 17))
    let subTitleLabel = UILabel().font(.systemFont(ofSize: 12)).textColor(.gray)

    init() {
        super.init(frame: CGRect.zero)

        addSubview(coverView)
        coverView.addSubview(titleLabel)
        coverView.addSubview(subTitleLabel)
        // ...
    }

    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }

    func configure(title: String, subtitle: String?) {
        titleLabel.text = title
        subTitleLabel.text = subtitle
    }
}

Usage

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

Installation

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

pod "ChainableSwift"

Then run pod install command.

Author

Denis Sushko, [email protected]

License

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

Latest podspec

{
    "name": "ChainableSwift",
    "version": "0.6.0",
    "summary": "Chainable standart library ud83dudd17",
    "description": "Easy to write and read chains of methods for UIView, UILabel, UIControl, UIButton, NSAttributedString, CALayer, etc. Work in progress.",
    "homepage": "https://github.com/respan/ChainableSwift",
    "license": "MIT",
    "authors": {
        "Denis Sushko": "[email protected]"
    },
    "source": {
        "git": "https://github.com/respan/ChainableSwift.git",
        "tag": "0.6.0"
    },
    "platforms": {
        "ios": "8.0"
    },
    "source_files": "ChainableSwift/Classes/**/*",
    "pushed_with_swift_version": "4.0"
}

Pin It on Pinterest

Share This