UIViewController
public extension UIViewController
A set of various extensions of the UIViewController class. These provide utilities for determining running state of the device, biometric support, and some responder stuff.
-
Get the biometric authentication type.
This is inspired by this SO answer
Possible Values:
- .none (no biometrics)
- .touchID (Touch ID)
- .faceID (Face ID)
Declaration
Swift
class var biometricType: LABiometryType { get }
-
Returns true, if we are in High Contrast Mode.
Declaration
Swift
class var isHighContrastMode: Bool { get }
-
Returns true, if we are in Reduced Transparency Mode.
Declaration
Swift
class var isReducedTransparencyMode: Bool { get }
-
Returns true, if voiceover mode is on.
Declaration
Swift
class var isVoiceOverRunning: Bool { get }
-
Returns true, if iCloud is available, and logged-in.
NOTE: If iCloud is available, but the user is not logged in, this will also return false.
Declaration
Swift
class var isICloudAvailable: Bool { get }
-
Returns the X/Y aspect of the screen (window).
Declaration
Swift
class var screenAspect: CGFloat { get }
-
Get the biometric authentication type.
Possible Values:
- .none (no biometrics)
- .touchID (Touch ID)
- .faceID (Face ID)
Declaration
Swift
var biometricType: LABiometryType { get }
-
Returns true, if we are in High Contrast Mode.
Declaration
Swift
var isHighContrastMode: Bool { get }
-
Returns true, if we are in Reduced Transparency Mode.
Declaration
Swift
var isReducedTransparencyMode: Bool { get }
-
Returns true, if voiceover mode is on.
Declaration
Swift
var isVoiceOverRunning: Bool { get }
-
Returns true, if iCloud is available, and logged-in.
NOTE: If iCloud is available, but the user is not logged in, this will also return false.
Declaration
Swift
var isICloudAvailable: Bool { get }
-
Returns true, if we are in Dark Mode.
Declaration
Swift
var isDarkMode: Bool { get }
-
Returns true, if haptics are available.
Declaration
Swift
var hapticsAreAvailable: Bool { get }
-
Returns the X/Y aspect of the screen (window).
Declaration
Swift
var screenAspect: CGFloat { get }
-
Returns the previous ViewController in a navigation stack. Nil, if at root, or not in a navigation stack. Inspired by this SO answer.
Declaration
Swift
var previousViewController: UIViewController? { get }
-
This returns the first responder, wherever it is in our hierarchy.
Declaration
Swift
var currentFirstResponder: UIResponder? { get }
-
This puts away any open keyboards. This is different from the UIView version, as it also forces
endEditing(_:)
.Declaration
Swift
func resignAllFirstResponders()