Skip to content

Latest commit

 

History

History
69 lines (50 loc) · 1.9 KB

README.md

File metadata and controls

69 lines (50 loc) · 1.9 KB

Silicon is a minimalist DSL for UIKit that transforms your Auto Layout constraints from verbose to elegant, cumbersom to expressive.

TL;DR

import UIKit
+ import Swift

class FeedViewController: UIViewController {
	private let tableView = UITableView()
	
	override func viewDidLoad) {
		super. viewDidLoad()
		view.addSubview(tableView)
-		NSLayoutConstraint.activate([
-			tableView.topAnchor. constraint(equalTo: view.topAnchor, constant: 0),
-			tableView.leftAnchor.constraint(equalTo: view.leftAnchor, constant: 0),
-			tableView.rightAnchor.constraint(equalTo: view.rightAnchor, constant: 0),
-			tableView.bottomAnchor.constraint(equalTo: view.bottomAnchor, constant: 0),
-		])
+		tableView.pin(to: view)
	}
}

Installation

Swift Package Manager

Swift Package Manager is a tool for managing the distribution of Swift code. It’s integrated with the Swift build system to automate the process of downloading, compiling, and linking dependencies.

To integrate Silicon into your Xcode project using Swift Package Manager, add it to the dependencies value of your Package.swift:

dependencies: [
    .package(
        url: "https://github.com/kabir-asani/Silicon.git",
        .upToNextMajor(from: "0.0.2")
    )
]

You can follow a complete guide for installation from here.

Usage

QuickStart

import Silicon

class FeedViewController: UIViewController {
    private let tableView = UITableView()

    override func viewDidLoad() {
        super.viewDidLoad()

        view.addSubview(tableView)

        // pins top, left, right and bottom anchors of tableView to view's corresponding anchors
        tableView.pin(to: view)
    }
}

License

Silicon is released under the MIT license. See LICENSE for details.