FortnightUtils 0.1.0

FortnightUtils 0.1.0

Maintained by Fortnight Studio.



FortnightUtils

Version License Platform

Banner

Description

FortnightUtils is a small library of functions and variables that allows you to quickly build your app programmatically. The aim of this library is to use these components without worrying about creating your own helper files and extensions in order to build out production applications.

Features.

Example

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

Requirements

This project requires Xcode 10+ running a target of iOS 9.3+ along with Cocoapods.

Installation

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

pod 'FortnightUtils'

Usage

Import

import FortnightUtils

UIColor

RGB color
let RGBColor = UIColor(r: 255, g: 255, b: 255, a: 1)
HEX color
let HEXColor = UIColor(hex: "#d73a49", alpha: 1)

UIButton

let button = UIButton.systemButton(title: "Title", image: nil, titleColor: .red, font: nil, target: self, selector: #selector(buttonSelector))

UILabel

Set characters spacing
myLabel.setCharactersSpacing(value: 2.5)
Set line height
myLabel.setLineHeight(value: 0.5)
// or
myLabel.setLineHeight(value: 0.5, lineBreakMode: byWordWrapping, alignment: .center)

lineBreakMode and alignment are optional parameters.

UITextView

Set characters spacing
myTextView.setCharactersSpacing(value: 2.5)
Set line height
myTextView.setLineHeight(value: 0.5)
// or
myTextView.setLineHeight(value: 0.5, alignment: .center)

alignment is an optional parameter.

UIView

Fill superview
myView.fillSuperView()
Center to superview
myView.anchorCenterSuperview()
Center Y axis to superview
myView.anchorCenterYToSuperview()
Center X axis to superview
myView.anchorCenterXToSuperview()
Anchor UIView
// Before
myView.topAnchor.constraint(equalTo: view.topAnchor, constant: 10).isActive = true
myView.leftAnchor.constraint(equalTo: view.leftAnchor, constant: 10).isActive = true
myView.bottomAnchor.constraint(equalTo: view.bottomAnchor, constant: 10).isActive = true
myView.rightAnchor.constraint(equalTo: view.rightAnchor, constant: 10).isActive = true

// After
myView.anchor(top: view.topAnchor, left: view.leftAnchor, bottom: view.bottomAnchor, right: view.rightAnchor, topConstant: 10, leftConstant: 10, bottomConstant: 10, rightConstant: 10, widthConstant: 0, heightConstant: 0)

UIViewController

let childViewController = ChildViewController()

self.add(childViewController) // Add child view controller
childViewController.remove() // Remove child view controller

UserDefaults

let isFirstLaunch = UserDefaults.isAppFirstLaunch
UserDefaults.setAppFirstLaunch()

Chached ImageView

Initializers
let cachedImageView = CachedImageView(cornerRadius: 5, emptyImage: emptyImage)
let cachedImageView = CachedImageView(cornerRadius: 5, tapCallback: callback)
let cachedImageView = CachedImageView(tapCallback: callback)
Load image async
cachedImageView.loadImage(urlString: "url", completion: {
    // Completion block
})

Author

Fortnight Studio, [email protected]

License

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