EXTENSION
public extension UIViewController
var classNameValue: String
ViewController class name
var titleColor: UIColor?
NavigationBar tint color
var titleFont: UIFont?
NavigationBar font
var viewIsVisible: Bool
Is view loaded and in window
var automaticallyHideKeyboardWhenViewTapped: Bool
Should hide keyboard on view tap
var bottomToolBar: UIView?
Add a bottom tool bar to view controller
var hidesNavigationBarBackgroundWhenVisible: Bool
Hide navigation bar background when visible
var navigationBarHeight: CGFloat
Navigation bar height
var tabBarHeight: CGFloat
Tab bar height
func addChild(viewController: UIViewController, in view: UIView)
Adds a child viewController to the current controller view
- Parameter viewController: The child view
Name | Description |
---|---|
viewController | The child view |
func removeChild(viewController: UIViewController)
Removes a child viewController from current
- Parameter viewController: The child view controller to remove
Name | Description |
---|---|
viewController | The child view controller to remove |
class func combine<Model, View>(models: [Model], into views: inout [View], newViewGeneration: () -> View, using operation: (Model, View) -> Void, remainingViews: (ArraySlice<View>) -> Void)
Combine an array of models and an array of views.
- Parameters:
- models: The models as data source.
- views: The views in need of loading data. Note that this is an inout parameters.
- newViewGeneration: The function to generate new views, which would immediately be appended into
views
. - operation: The main operation that combine each model and view together.
- remainingViews: The handler responsible for dealing with the rest of unused views.
Name | Description |
---|---|
models | The models as data source. |
views | The views in need of loading data. Note that this is an inout parameters. |
newViewGeneration | The function to generate new views, which would immediately be appended into views . |
operation | The main operation that combine each model and view together. |
remainingViews | The handler responsible for dealing with the rest of unused views. |
func showSystemAlert(
title: String?,
message: String? = nil,
confirmTitle: String? = nil,
confirmHandler: (() -> Void)? = nil,
cancelTitle: String = "Cancel",
cancelHandler: (() -> Void)? = nil)
Present system alert
- Parameters:
- title: Title
- message: Message
- confirmTitle: Confirm button title
- confirmHandler: Confirm handler to run on press
- cancelTitle: Cancel button title
- cancelHandler: Cancel handler to run on press
Name | Description |
---|---|
title | Title |
message | Message |
confirmTitle | Confirm button title |
confirmHandler | Confirm handler to run on press |
cancelTitle | Cancel button title |
cancelHandler | Cancel handler to run on press |
showSystemDistructiveAlert(title:message:destructiveTitle:destructiveHandler:cancelTitle:cancelHandler:)
func showSystemDistructiveAlert(
title: String?,
message: String? = nil,
destructiveTitle: String?,
destructiveHandler: (() -> Void)?,
cancelTitle: String?,
cancelHandler: (() -> Void)? = nil)
Present system alert with distructive primary action
- Parameters:
- title: Title
- message: Message
- confirmTitle: Confirm button title
- confirmHandler: Confirm handler to run on press
- cancelTitle: Cancel button title
- cancelHandler: Cancel handler to run on press
Name | Description |
---|---|
title | Title |
message | Message |
confirmTitle | Confirm button title |
confirmHandler | Confirm handler to run on press |
cancelTitle | Cancel button title |
cancelHandler | Cancel handler to run on press |
func showSystemActionSheet(title: String?, message: String?, validActions: (String?, (() -> Void)?)...)
Present action sheet
- Parameters:
- title: Title
- message: Message
- actions: Actions in the sheet
Name | Description |
---|---|
title | Title |
message | Message |
actions | Actions in the sheet |
@IBAction func resignTextFieldToHideKeyboard(_ sender: AnyObject)
Resign keyboard
class func getCurrentViewController(base: UIViewController? = UIApplication.shared.keyWindow?.rootViewController) -> UIViewController?
Get the current visible view controller by crawling the view controller heirarchy
- Parameter base:
UIViewController
to search - Returns: Current
UIViewController
Name | Description |
---|---|
base | UIViewController to search |
func popFromNavigationStack()
Pop view controller from nav stack
func addDismissNavigationItem(localizedTitle: String = "Dismiss", image: UIImage? = nil)
Add dismiss UIBarButtonItem
naviation item
@objc func dismissSelf(_ sender: Any)
func pushSafariViewController(urlString: String, entersReaderIfAvailable: Bool = false)