Lilith 0.1.10

Lilith 0.1.10

TestsTested
LangLanguage SwiftSwift
License MIT
ReleasedLast Release Jul 2016
SPMSupports SPM

Maintained by Josh Arnold.



Lilith 0.1.10

  • By
  • Josh Arnold

Lilith Banner

Lilith is a UI Library written in Swift designed to make working with UIKit faster and more user friendly.

Lilith is in early Alpha and is under heavy development. More features and full documentation coming soon. ❤️

Requirements

  • iOS 8.0+
  • Xcode 7.3+

Installation

Lilith is available through CocoaPods. To install it, simply add the following line to your Podfile:

pod "Lilith"

Documentation

Full documentation is available over at Cocoadocs!

Usage

Text based classes

LFConfiguration

LFConfigurations are a set of appearance properties that can be applied to Lilith’s text based classes.

let config = LFConfiguration(font: UIFont(name: "Avenir Next", size: 20)!, textColor: .blackColor(), textAlignment: .Center, numberOfLines: 0, resize: true)

LFLabel

Once you’ve created a LFConfiguration, you can then use it to configure classes such as the LFLabel. This allows you to avoid having to retype excessive code. 😏

//A label made with Lilith
let frame = CGRect(x: 16, y: 32, width: view.frame.width-32, height: 64)
let label = LFLabel(frame: frame, configuration: config, text: "Hello world!")
view.addSubview(label)

Lilith LFLabel

Here is what the same label would look like using the default UIKit. Look at how much code it is! 😲

//Original label made with UIKit
let frame = CGRect(x: 16, y: 0, width: view.frame.width-32, height: 64)
let label = UILabel(frame: frame)
label.text = "Hello world!"
label.font = UIFont(named:"Avenir Next", size:20)
label.textColor = .BlackColor
label.textAlignment = .Left
label.numberOfLines = 0
label.sizeToFit()
view.addSubview(label)

LFButton

Remember, LFConfigurations can be used for all text based classes, for example LFButton. The same properties from the configuration that are applied to the above LFLabel can be directly applied to an LFButton without having to retype the same code. Oh, and should I mention Lilith has custom initializers to help speed up your coding 😘.

//Create a LFButton with the full width of the view at a certain point and adjust the height automatically
let button = LFButton(text: "Click me", view: view, point: 0, configuration: config)  
button.below(label2, padding: 16) //Move's the button below a certain view with optional padding
button.target("doSomething", object: self) //Quickly Target a method (assumes the control event is TouchUpInside)  
view.addSubview(button)

Sexy Extras

Lilith’s text based classes come loaded with many different functions all with the one purpose of simplifying your UI code! 😎

// Sets the text color. For LFButtons it automatically lightens or darkens the color for the highlighted state
textColor(textColor: UIColor)

// Sets the font size of the current font
fontSize(size: CGFloat)

// Moves the object below a certain view with optional padding. (A fast replacement for CGRectGetMaxY)
below(view: UIView, padding: CGFloat)

// Moves the object above a certain view with optional padding. (A fast replacement for CGRectGetMinY)
above(view: UIView, padding: CGFloat)

// These functions will adjust the alignment of the text. Even for the LFButton.
leftText()
centerText()
rightText()

//Sets the number of lines for a label.
lines(lines: Int)

// Automatically adjusts the height of the object to fit it's text while maintaining the width.
resize()

// For LFButtons only. Sets the title for both the normal and highlighted state.
setText(text: String)

// Resets the objects entire configuration with a new one.
setConfiguration(configuration: LFConfiguration)

// For buttons only. Adds a target for the touch up inside event.
target(action: String, object: AnyObject)

Example

To run the example project, clone the repo, and run pod install from the Example directory first.

Author

Josh Arnold, [email protected]

License

Lilith is available under the MIT license. See the LICENSE file for more info.