Giter Club home page Giter Club logo

contentkit's Introduction

ContentKit

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 {
	print(line)
}
// 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

License

AGPL-3.0

contentkit's People

Contributors

danieldahan avatar

Stargazers

MohsinAli avatar

Watchers

MohsinAli avatar Carabineiro avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.