UIView

public extension UIView
  • Consider view with alpha <0.01 as invisible because it stops receiving touches at this level: “This method ignores view objects that are hidden, that have disabled user interactions, or have an alpha level less than 0.01”. This one also checks all superviews for the same parameters.

    Declaration

    Swift

    var isVisible: Bool { get }
  • Checks wheter view is visible in containing window.

    Declaration

    Swift

    var isVisibleInWindow: Bool { get }

Sizes

  • View width

    Declaration

    Swift

    var width: CGFloat { get set }
  • View height

    Declaration

    Swift

    var height: CGFloat { get set }
  • View size

    Declaration

    Swift

    var size: CGSize { get set }

Animations

  • Checks if code runs inside animation closure

    Declaration

    Swift

    @available(iOS 9.0, *)
    static var isInAnimationClosure: Bool { get }
  • Returns true if view can be animated. That means window is not nil and application state is .active.

    Declaration

    Swift

    var isAnimatable: Bool { get }
  • Undocumented

    Declaration

    Swift

    func fadeInAnimated()
  • Undocumented

    Declaration

    Swift

    func fadeOutAnimated()

Utils

  • Makes corner radius euqal to half of width or height

    Declaration

    Swift

    func makeRound()
  • Returns closest UIViewController from responders chain.

    Declaration

    Swift

    var viewController: UIViewController? { get }
  • Gets view’s top most superview

    Declaration

    Swift

    var rootView: UIView { get }

Sequence

  • Returns all view’s subviews

    Declaration

    Swift

    var allSubviews: [UIView] { get }
  • Returns all view’s subviews

    Declaration

    Swift

    var allVisibleSubviews: [UIView] { get }
  • All view superviews to the top most

    Declaration

    Swift

    var superviews: DropFirstSequence<UnfoldSequence<UIView, (UIView?, Bool)>> { get }
  • All view superviews to the top most

Image

  • Creates image from view and adds overlay image at the center if provided

    Declaration

    Swift

    func getSnapshotImage() -> UIImage?

Responder Helpers

  • Ends editing on view and all of it’s subviews

    Declaration

    Swift

    @IBAction
    func endEditing()
  • Checks if window is not nil before calling becomeFirstResponder()

    Declaration

    Swift

    func becomeFirstResponderIfPossible()

Activity Indicator

  • Is activity indicator showing?

    Declaration

    Swift

    var isShowingActivityIndicator: Bool { get }
  • Shows activity indicator. It uses existing one if found in subviews. Calls to -showActivityIndicator and -hideActivityIndicator have to be balanced or hide have to be forced.

    Declaration

    Swift

    func showActivityIndicator()
  • Hides activity indicator. Calls to -showActivityIndicator and -hideActivityIndicator have to be balanced or hide have to be forced.

    Declaration

    Swift

    func hideActivityIndicator(force: Bool = false)

    Parameters

    force

    Force activity indicator hide

Constraints

  • Creates constraints between self and provided view for top, bottom, leading and trailing sides.

    Declaration

    Swift

    @available(iOS 9.0, *)
    func constraintSides(to containerView: UIView, insets: UIEdgeInsets = .zero)

    Parameters

    containerView

    Container view containing self.

    insets

    Insets to the containerView. .zero by default.

Border

  • Undocumented

    Declaration

    Swift

    @IBInspectable
    var borderColor: UIColor? { get set }
  • Undocumented

    Declaration

    Swift

    @IBInspectable
    var borderWidth: CGFloat { get set }
  • Sets border width equal to 1 pixel

    Declaration

    Swift

    @IBInspectable
    var borderOnePixelWidth: Bool { get set }

Corner Radius

  • Undocumented

    Declaration

    Swift

    @IBInspectable
    var cornerRadius: CGFloat { get set }

Shadow

  • Undocumented

    Declaration

    Swift

    @IBInspectable
    var shadowColor: UIColor? { get set }
  • Undocumented

    Declaration

    Swift

    @IBInspectable
    var shadowOffset: CGPoint { get set }
  • Undocumented

    Declaration

    Swift

    @IBInspectable
    var shadowOpacity: Float { get set }
  • Undocumented

    Declaration

    Swift

    @IBInspectable
    var shadowRadius: CGFloat { get set }
  • Apply square path for shadow. This increases performance for shadow drawing in case shadow is square.

    Declaration

    Swift

    @IBInspectable
    var shadowApplyPath: Bool { get set }
  • Undocumented

    See more

    Declaration

    Swift

    enum ViewState
  • Undocumented

    Declaration

    Swift

    func configure(viewState: ViewState)