Simplifier

`Simplifier` is the pack of popular extensions


License
MIT
Install
pod try Simplifier

Documentation

Simplifier

CI Status Version License Platform

Simplifier is the pack of popular extensions

Example

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

Installation

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

pod "Simplifier"

Usage

Dictionary

Compose dictionaries

var dict = ["one":1]
dict += ["two":2] + ["three":3] //["two": 2, "one": 1, "three": 3]

UIView

Make view border with round corners

myView.makeRoundBorder(ofColor: .black, width: 1, radius: 3)

Add constraints to view

myView.addConstaintsToSuperview(leftOffset: 0, topOffset: 0)
myView.addConstaints(height: 64, width: 64)

Take a screenshot of your view

let screenshot:UIImage = myView.snapshotImage

UIViewController

Take content view controller of your navigation controller

let contentVC = destinationVC.contentViewController

Data

Build data in current Calendar with single method and take date components

let dt = Date.from(year: 2017, month: 6, day: 25, hour: 12)
dt.month // 6
dt.year // 2017

Array

Safe array subscript returns optional

let optionalElement = array[safe: 15]

UIImage

Make UIImage of color with rounded corners

let image = UIImage.ofColor(.red, size: size, cornerRadius: 5)

Create gradient image

let gradient = Gradient(direction:.leftRight, size:CGSize(width:50, height:10), startColor:.red, endColor:.yellow)
let gradientImage = UIImage.gradientImage(gradient)

Gaussian blur for UIImage with radius:

let imageWithBlur = myImage.blurImage(radius: 8)

Get pixel color for image

let color = myImage.pixelColor(for: CGPoint(x:10, y:10))

Get pixel color for image

let color = myImage.pixelColor(for: CGPoint(x:10, y:10))

Transform image to single color template

let maskedImage = myImage.maskWithColor(color: .blue)

String

Get right endings for russian countable nouns

for i in 1...7 {
    print(String(i)+" "+String.russianWordFor(number: i, one: "яйцо", two: "яйца", five: "яиц"))
}

Output:

1 яйцо
2 яйца
3 яйца
4 яйца
5 яиц
6 яиц
7 яиц

Author

Alex Shubin, Interactive Services, alexshubin22@gmail.com, alexshubin22@gmail.com

License

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