An Elegant Content Framework In Swift

Language: Swift


CocoaPods Support

ContentKit is on CocoaPods under the name CK.

Resize Image

Images come in all shapes and sizes. UIImage resize is a flexible way to resize images on the fly. The below example shows you how.

let p1: UIImage? = UIImage(named: "img1")
let p2: UIImage? = p1?.resize(toWidth: 300)
let p3: UIImage? = p1?.resize(toHeight: 200)

Crop Image

Crop images easily with UIImage crop. Below is an example:

let p1: UIImage? = UIImage(named: "img1")
let p2: UIImage? = p1?.crop(toWidth: 400, toHeight: 200)

Save To Photo Library

Keep the moment by saving your images to Photo Library. Below is an example of cropping an image and saving it to the devices PhotoLibrary.

let p: UIImage? = UIImage(named: "img1")
p?.crop(toWidth: 400, toHeight: 200)?.writeToPhotoLibrary()

Lines of Text

Cycle through lines of text in any String. Below is an example of iterating through all lines of text in a String.

let text: String = "This is a\nblock of text\nthat has\nnewlines."
for line in text.lines {
// output:
// This is a
// block of text
// that has
// newlines.

Trim Whitespace

Remove the spaces and newlines from the beginning and end of a text block. Below is an example.

let text: String = "     \n  Hello World    \n     "
print(text.trim()) // output: Hello World

File System

Get helpful directories.

print(File.applicationDirectoryPath) // output: ../Applications/
print(File.documentDirectoryPath) // output: ../Documents/
print(File.libraryDirectoryPath) // output: ../Library/
print(File.cachesDirectoryPath) // output: ../Library/Caches/
print(File.tmpDirectoryPath)  // output: ../tmp/

Create Directory

Easily create directories in different search paths.

let result: Bool = File.createDirectory("TestDirectory", inDirectory: .DocumentDirectory)
print(result) // output: true

Remove Directory

As simple as it is to create a directory, it is to remove it.

let result: Bool = File.removeDirectory("TestDirectory", inDirectory: .DocumentDirectory)
print(result) // output: true



Project Statistics

Sourcerank 2
Repository Size 116 KB
Stars 1
Forks 1
Open issues disabled
Dependencies 0
Contributors 1
Tags 7
Last updated
Last pushed

Top Contributors See all

Daniel Jonathan

Recent Tags See all

0.1.6 October 26, 2015
0.1.5 October 25, 2015
0.1.4 October 23, 2015
0.1.3 October 22, 2015
0.1.2 October 22, 2015
0.1.1 October 16, 2015
0.1.0 October 16, 2015

Something wrong with this page? Make a suggestion

Last synced: 2017-03-10 16:47:15 UTC

Login to resync this repository