Useful extensions for UIKit in Swift as follows.
// Create UIColor instance by hex integer value
let darkOrange = UIColor(hex:0xFF8C00)
Copy *.swift to your project.
// UIControl
let button = UIButton.buttonWithType(UIButtonType.Custom) as UIButton!
button.enable()
button.disable()
// UIColor
let darkOrange = UIColor(hex:0xFF8C00)
// UIView
let title = UILabel(frame: CGRect(x: 50, y: 80, width: 200, height: 50))
title.text = "Hello, World"
title.sizeToFit()
title.centerHorizontally(320)
// UITableView
self.tableView.scrollToBottom()
// UIConstants
let width = UIConstants.screenWidth()
let height = UIConstants.screenHeight()
Method |
Description |
func enable() |
Enable UIControl (.enabled = true) |
func disable() |
Disable UIControl (.enabled = false) |
Method |
Description |
init(hex: Int) |
let darkOrange = UIColor(hex:0xFF8C00) |
Method |
Description |
func centerHorizontally(parentWidth: Double) |
Centering UIView holizontally. See Examples below. |
Method |
Description |
func scrollToBottom(animated: Bool = true) |
tableView.scrollToBottom() |
Method |
Description |
func screenWidth() |
UIConstants.screenWidth() |
func screenHeight() |
UIConstants.screenHeight() |
The MIT License (MIT)