TestsTested | ✗ |
LangLanguage | SwiftSwift |
License | MIT |
ReleasedLast Release | Jun 2017 |
SwiftSwift Version | 3.1 |
SPMSupports SPM | ✗ |
Maintained by Interactive Services.
Simplifier
is the pack of popular extensions
To run the example project, clone the repo, and run pod install
from the Example directory first.
Simplifier is available through CocoaPods. To install it, simply add the following line to your Podfile:
pod "Simplifier"
Compose dictionaries
var dict = ["one":1]
dict += ["two":2] + ["three":3] //["two": 2, "one": 1, "three": 3]
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
Take content view controller of your navigation controller if needed
let contentVC = destinationVC.contentViewController
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
Safe collection subscript - returns optional
let optionalElement = array[safe: 15]
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)
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)
Easily create NSAttributedString
let attrStr = NSAttributedString(string: "STR", font: font.withSize(10), color: .red)
Alex Shubin, Interactive Services, [email protected], [email protected]
Simplifier is available under the MIT license. See the LICENSE file for more info.