Latest 0.1.2
Homepage https://github.com/interactiveservices/Simplifier
License MIT
Platforms ios 8.0
Authors

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 if needed

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

Collection

Safe collection 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))

Transform image to single color template

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

Crop image to sqare

let cropped = myImage.squareCroppedImage()

Scale image to size

let resized = myImage.scaledTo(size:mySize)

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 яиц

Generate an image from string

let myImage = "STR".generateImage(of: CGSize(width:50,height:50), font: UIFont.systemFont(ofSize: 10), color: .red)

NSAttributedString

Easily create NSAttributedString

let attrStr = NSAttributedString(string: "STR", font: font.withSize(10), color: .red)

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.

Latest podspec

{
    "name": "Simplifier",
    "version": "0.1.2",
    "summary": "`Simplifier` is the pack of popular extensions",
    "description": "Extensions for:n- Dictionaryn- UIViewn- UIViewControllern- Daten- Arrayn- UIImagen- String",
    "homepage": "https://github.com/interactiveservices/Simplifier",
    "license": {
        "type": "MIT",
        "file": "LICENSE"
    },
    "authors": {
        "alexshubin22@gmail.com": "alexshubin22@gmail.com"
    },
    "source": {
        "git": "https://github.com/interactiveservices/Simplifier.git",
        "tag": "0.1.2"
    },
    "platforms": {
        "ios": "8.0"
    },
    "source_files": "Simplifier/Classes/**/*",
    "pushed_with_swift_version": "3.1"
}

Pin It on Pinterest

Share This