UIView
public extension UIView
Provide a screenshot function for any view
Date
08/05/2019Version
1.5.0-
The screenshot created for the view.
Declaration
Swift
func screenshot(withScale scale: Double = 1) -> UIImage?Parameters
scaleThe scale of the screenshot
Return Value
The screenshot
-
The default localization file.
Declaration
Swift
static let defaultLocalizationFile: String -
Localize the view.
Declaration
Swift
@objc func localize(withLocalizationFile localizationFile: String = defaultLocalizationFile)Parameters
localizationFileThe string file where all strings are stored.
-
The default animation period.
Declaration
Swift
static let defaultAnimationDuration: Double -
Whether or not the view is performing an animation
Declaration
Swift
var isAnimating: Bool { get } -
Perform an animation.
Declaration
Swift
func animateChange(_ change: @escaping () -> Void, withDuration duration: Double = defaultAnimationDuration, preparation: (() -> Void) = {}, completion: @escaping (() -> Void) = {})Parameters
changeThe change to be animated.
durationThe period of the animation.
preparationThe action to be done before the animation.
completionThe action to be done after the animation.
-
Stop any animation executed on the current view.
Declaration
Swift
func stopAllAnimations() -
Update the visibility with animation
Declaration
Swift
func animateVisibility(_ isVisible: Bool, withDuration duration: Double = defaultAnimationDuration, completion: @escaping (() -> Void) = {})Parameters
isVisibleThe new visibility
durationThe duration of the animation
completionThe action to perform after the animation
-
Show the view.
Declaration
Swift
func show(withDuration duration: Double = defaultAnimationDuration, completion: @escaping (() -> Void) = {})Parameters
durationDuration of the animation.
completionCallback when the view is shown.
-
Hide the view.
Declaration
Swift
func hide(withDuration duration: Double = defaultAnimationDuration, completion: @escaping (() -> Void) = {})Parameters
durationDuration of the animation.
completionCallback when the view is shown.
-
The constraints related to the frame of the view. These constraints is usually added to superview.
Declaration
Swift
var frameConstraints: [NSLayoutConstraint] { get } -
The border color of a view
Declaration
Swift
@IBInspectable var borderColor: UIColor? { get set } -
The border width of a view
Declaration
Swift
@IBInspectable var borderWidth: CGFloat { get set } -
The corner radious of a view
Declaration
Swift
@IBInspectable var cornerRadius: CGFloat { get set } -
The shadow inset
Declaration
Swift
@IBInspectable var shadowInset: CGSize { get set } -
The shadow opacity
Declaration
Swift
@IBInspectable var shadowOpacity: Float { get set } -
The shadow color
Declaration
Swift
@IBInspectable var shadowColor: UIColor? { get set } -
Colors for the gradient effect
Declaration
Swift
var gradientColors: [UIColor]? { get set } -
The width attribute
Declaration
Swift
@available(iOS 10.0, *) var width: CGFloat? { get set } -
The height attribute
Declaration
Swift
@available(iOS 10.0, *) var height: CGFloat? { get set } -
The top space to its superview
Declaration
Swift
@available(iOS 10.0, *) var top: CGFloat? { get set } -
The left space to its superview
Declaration
Swift
@available(iOS 10.0, *) var left: CGFloat? { get set } -
The right space to its superview
Declaration
Swift
@available(iOS 10.0, *) var right: CGFloat? { get set } -
The bottom space to its superview
Declaration
Swift
@available(iOS 10.0, *) var bottom: CGFloat? { get set } -
Pin the edge to its superview
Declaration
Swift
func pinEdgesToSuperview(with edgeInsets: UIEdgeInsets = .zero)Parameters
edgeInsetsThe edge insets. If one inset is not necessary to be settled, set it to be .invalidInset
-
Pin the horizontal edges to its superview
Declaration
Swift
func pinHorizontalEdgesToSuperview() -
Pin the horizontal edges to its superview
Declaration
Swift
func pinVerticalEdgesToSuperview() -
Enable the any gesture on the view.
Declaration
Swift
func enableAnyGesture() -
Disable the any gesture on the view.
Declaration
Swift
func disableAnyGesture() -
Enable a gesture.
Declaration
Swift
func enableGesture(ofType type: UIGestureRecognizer.Type)Parameters
typeThe type of gesture to be disabled.
-
Disable a gesture.
Declaration
Swift
func disableGesture(ofType type: UIGestureRecognizer.Type)Parameters
typeThe gesture to be disabled.
UIView Extension Reference