A collection of Swift extensions that reduce boilerplate code in new iOS projects
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
WybroStarter.xcodeproj
WybroStarter
.gitignore
.swift-version
LICENSE
README.md
WybroStarter.podspec

README.md

WybroStarter

This pod contains a collection of Swift extensions that reduce boilerplate code in new iOS projects

Getting Started

Add the following line to your Podfile:

pod 'WybroStarter'

Swift Extensions

We have added new functionality to UIView, NSLayoutConstraint and UIColor to make it easier to build projects without xib files

UIView

Constraints

Specify that a view will be using constraints. A good time to do this is while the view is being added as a subview:

view.addSubview(yourView.usingConstraints())

Centering

Center a view horizontally or vertically within another view:

let horizontal = yourView.center(in: view, type: .horizontal)
let vertical = yourView.center(in: view, type: .vertical)

NSLayoutConstraint

Create constraints for multiple views and formats with VFL:

let constraints = NSLayoutConstraint.constraints(
      formats: ["V:|[view]|",
                "H:|[view]|"],
      views: ["view": yourView]
)

A nice pattern to follow involves creating a function to return the constraints you want and chaining an activate to enable all of the constraints:

func layoutConstraints() -> [NSLayoutConstraint] {
  // create constraints here
  return constraints
}

layoutConstraints().activate()

UIColor

Create an instance of UIColor using a hex string:

let color = UIColor(hex: "FFFFFF")