Pomegranate is all about creating easy UI for your applications. Inside this library you have a bunch of class extensions to help you build beautiful apps and make hard tasks easy.
Pomegranate is divided in 6 components:
As the name suggests, this is a UIView class extension to add gradients to views. It works like this:
myView.addGradient(beginningColor: .blue, endingColor: .yellow, type:
.leftToRight, animated: true)
This will create something like this:
The possible gradient types are:
- .leftToRight
- .rightToLeft
- .diagonalLeftToRight
- .diagonalRightToLeft
- .topToBottom
- .bottomToTop
Other functions available:
Function | Parameters | Use |
---|---|---|
addGRadientWithMultipleColors() | [CGColor], type, animated | Adds gradient with multiple colors |
deleteGradient() | animated | Deletes all of the gradients on the current view |
Note: This will remove all of the gradients on that view.
Downloading images from a URL can be awkward sometimes, that's where Downloaderr comes to the rescue. Downloaderr is a UIImageView extension used to download images from a URL and even put a placeholder while the download is happening. Downloaderr also saves your images on a temporary cache so you don't download the same image twice.
It works as follows:
myImageView.downloadImageWith(url: NSURL(string: "https://upload.wikimedia.org/wikipedia/en/3/39/Wakerlink.jpg")!, placeholder: UIImage(named: "placeholder")!)
Other functions available:
Function | Parameters | Use |
---|---|---|
downloadImageFrom(url:) | url | download Image from a URL without placeholder |
This is a Date class extension that provides different options in converitng a string into a Date or vice versa. It works like this:
Creating Dates:
let date = Date(dateInString: "15/03/2017",dateFormat: "dd/MM/yyyy")!
Converting dates to strings:
string = date.toTimeLanguage()
string = date.toTimeLanguage([.oneDayago:"Yesterday"])
string = date.convertTo(format: .short)
string = date.convertTo(format: .custom("dd-MM-yyyy"))
Possible formats for converting dates to strings:
- .full
- .short
- .medium
- .long
- .weekDay
- .custom(String)
Time language formats to customize:
Format | Custom string |
---|---|
.rightNow | A moment ago |
.oneDayAgo | One day ago |
.oneYearAgo | One year ago |
.yearsAgo | (years) years ago |
.daysAgo | (days) days ago |
.minutesAgo | (minutes) minutes ago |
.oneMinuteAgo | One minute ago |
Adding attributes to a string is pretty weird, let's face it. We decided to make it easier like such:
myLabel.attributedText = Attributerr.sharedAttributerr.create(string: "Hello World!", backgroundColor: .red, font: .systemFont(ofSize: 20), color: .blue, underLineStyle: 0)
This will create something like this:
All of the parameters except the string value have default values, so you don't need to set them all on the function call.
This are the default values used:
- backgroundColor = .clear
- font = UIFont(name: "System", size: 12)!
- color = .black
- underLineStyle = 0
This segment comes with other handy functions like the following:
Function | Parameters | Use |
---|---|---|
addAttributesToRange() | string, NSRange, attributes | Add attributes to a NSRange |
addAttributesToSubstring() | string, substring, attributes | Adds attributes to a substring of your string |
The attributes parameter is the list of available parameters that have default values.
This is a UIColor extension that provides popular color options to create beautiful UI.
Color options:
- SocialMedia
- Red
- Green
- Purple
- Blue
- Gray
- Yellow
- Orange
- Pink
Each color let's you pick the intensity, for example:
UIColor.Colorerr.Blue.dark
The intensities can be:
- dark
- light
- regular
This is a head start in creating a page view that is used for an introduction of an application. It looks somthing like this:
To get started in creating one, you can do this:
let vc = PageViewController()
vc.titles = ["Title1","Title2","Title3"]
self.navigationController?.pushViewController(vc, animated: true)
To run the example project, clone the repo, and run pod install
from the Example directory first.
Pomegranate is available through CocoaPods. To install it, simply add the following line to your Podfile:
pod "Pomegranate"
Pomegranate is available under the MIT license. See the LICENSE file for more info.