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
@MainActor class var biometricType: LABiometryType { get }
-
Returns true, if we are in High Contrast Mode.
Declaration
Swift
@MainActor class var isHighContrastMode: Bool { get }
-
Returns true, if we are in Reduced Transparency Mode.
Declaration
Swift
@MainActor class var isReducedTransparencyMode: Bool { get }
-
Returns true, if voiceover mode is on.
Declaration
Swift
@MainActor 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
@MainActor class var isICloudAvailable: Bool { get }
-
Returns the X/Y aspect of the screen (window).
Declaration
Swift
@MainActor class var screenAspect: CGFloat { get }
-
Get the biometric authentication type.
Possible Values:
- .none (no biometrics)
- .touchID (Touch ID)
- .faceID (Face ID)
Declaration
Swift
@MainActor var biometricType: LABiometryType { get }
-
Returns true, if we are in High Contrast Mode.
Declaration
Swift
@MainActor var isHighContrastMode: Bool { get }
-
Returns true, if we are in Reduced Transparency Mode.
Declaration
Swift
@MainActor var isReducedTransparencyMode: Bool { get }
-
Returns true, if voiceover mode is on.
Declaration
Swift
@MainActor 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
@MainActor var isICloudAvailable: Bool { get }
-
Returns true, if we are in Dark Mode.
Declaration
Swift
@MainActor var isDarkMode: Bool { get }
-
Returns true, if haptics are available.
Declaration
Swift
@MainActor var hapticsAreAvailable: Bool { get }
-
Returns the X/Y aspect of the screen (window).
Declaration
Swift
@MainActor 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
@MainActor var previousViewController: UIViewController? { get }
-
This returns the first responder, wherever it is in our hierarchy.
Declaration
Swift
@MainActor var currentFirstResponder: UIResponder? { get }
-
This puts away any open keyboards. This is different from the UIView version, as it also forces
endEditing(_:)
.Declaration
Swift
@MainActor func resignAllFirstResponders()