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.
To run the example project, clone the repo, and run pod install
from the Example directory first.
This project requires Xcode 10+ running a target of iOS 9.3+ along with Cocoapods.
FortnightUtils is available through CocoaPods. To install it, simply add the following line to your Podfile:
pod 'FortnightUtils'
import FortnightUtils
let RGBColor = UIColor(r: 255, g: 255, b: 255, a: 1)
let HEXColor = UIColor(hex: "#d73a49", alpha: 1)
let button = UIButton.systemButton(title: "Title", image: nil, titleColor: .red, font: nil, target: self, selector: #selector(buttonSelector))
myLabel.setCharactersSpacing(value: 2.5)
myLabel.setLineHeight(value: 0.5)
// or
myLabel.setLineHeight(value: 0.5, lineBreakMode: byWordWrapping, alignment: .center)
lineBreakMode and alignment are optional parameters.
myTextView.setCharactersSpacing(value: 2.5)
myTextView.setLineHeight(value: 0.5)
// or
myTextView.setLineHeight(value: 0.5, alignment: .center)
alignment is an optional parameter.
myView.fillSuperView()
myView.anchorCenterSuperview()
myView.anchorCenterYToSuperview()
myView.anchorCenterXToSuperview()
// 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)
let childViewController = ChildViewController()
self.add(childViewController) // Add child view controller
childViewController.remove() // Remove child view controller
let isFirstLaunch = UserDefaults.isAppFirstLaunch
UserDefaults.setAppFirstLaunch()
let cachedImageView = CachedImageView(cornerRadius: 5, emptyImage: emptyImage)
let cachedImageView = CachedImageView(cornerRadius: 5, tapCallback: callback)
let cachedImageView = CachedImageView(tapCallback: callback)
cachedImageView.loadImage(urlString: "url", completion: {
// Completion block
})
Fortnight Studio, development@fortnight.studio
FortnightUtils is available under the MIT license. See the LICENSE file for more info.