UIView

class UIView : UIResponder, NSCoding, UIAppearance, UIAppearanceContainer, UIDynamicItem, UITraitEnvironment, UICoordinateSpace, UIFocusItem, CALayerDelegate
  • SwifterSwift: Border color of view; also inspectable from Storyboard.

    Declaration

    Swift

    @IBInspectable
    public var borderColor: UIColor? { get set }
  • SwifterSwift: Border width of view; also inspectable from Storyboard.

    Declaration

    Swift

    @IBInspectable
    public var borderWidth: CGFloat { get set }
  • SwifterSwift: Corner radius of view; also inspectable from Storyboard.

    Declaration

    Swift

    @IBInspectable
    public var cornerRadius: CGFloat { get set }
  • SwifterSwift: Height of view.

    Declaration

    Swift

    public var height: CGFloat { get set }
  • SwifterSwift: Check if view is in RTL format.

    Declaration

    Swift

    public var isRightToLeft: Bool { get }
  • SwifterSwift: Take screenshot of view (if applicable).

    Declaration

    Swift

    public var screenshot: UIImage? { get }
  • SwifterSwift: Shadow color of view; also inspectable from Storyboard.

    Declaration

    Swift

    @IBInspectable
    public var shadowColor: UIColor? { get set }
  • SwifterSwift: Shadow offset of view; also inspectable from Storyboard.

    Declaration

    Swift

    @IBInspectable
    public var shadowOffset: CGSize { get set }
  • SwifterSwift: Shadow opacity of view; also inspectable from Storyboard.

    Declaration

    Swift

    @IBInspectable
    public var shadowOpacity: Float { get set }
  • SwifterSwift: Shadow radius of view; also inspectable from Storyboard.

    Declaration

    Swift

    @IBInspectable
    public var shadowRadius: CGFloat { get set }
  • SwifterSwift: Size of view.

    Declaration

    Swift

    public var size: CGSize { get set }
  • SwifterSwift: Get view’s parent view controller

    Declaration

    Swift

    public var parentViewController: UIViewController? { get }
  • SwifterSwift: Width of view.

    Declaration

    Swift

    public var width: CGFloat { get set }
  • x

    SwifterSwift: x origin of view.

    Declaration

    Swift

    public var x: CGFloat { get set }
  • y

    SwifterSwift: y origin of view.

    Declaration

    Swift

    public var y: CGFloat { get set }
  • SwifterSwift: Recursively find the first responder.

    Declaration

    Swift

    public func firstResponder() -> UIView?
  • SwifterSwift: Set some or all corners radiuses of view.

    Declaration

    Swift

    public func roundCorners(_ corners: UIRectCorner, radius: CGFloat)

    Parameters

    corners

    array of corners to change (example: [.bottomLeft, .topRight]).

    radius

    radius for selected corners.

  • SwifterSwift: Add shadow to view.

    Declaration

    Swift

    public func addShadow(ofColor color: UIColor = UIColor(red: 0.07, green: 0.47, blue: 0.57, alpha: 1.0), radius: CGFloat = 3, offset: CGSize = .zero, opacity: Float = 0.5)

    Parameters

    color

    shadow color (default is #137992).

    radius

    shadow radius (default is 3).

    offset

    shadow offset (default is .zero).

    opacity

    shadow opacity (default is 0.5).

  • SwifterSwift: Add array of subviews to view.

    Declaration

    Swift

    public func addSubviews(_ subviews: [UIView])

    Parameters

    subviews

    array of subviews to add to self.

  • SwifterSwift: Fade in view.

    Declaration

    Swift

    public func fadeIn(duration: TimeInterval = 1, completion: ((Bool) -> Void)? = nil)

    Parameters

    duration

    animation duration in seconds (default is 1 second).

    completion

    optional completion handler to run with animation finishes (default is nil)

  • SwifterSwift: Fade out view.

    Declaration

    Swift

    public func fadeOut(duration: TimeInterval = 1, completion: ((Bool) -> Void)? = nil)

    Parameters

    duration

    animation duration in seconds (default is 1 second).

    completion

    optional completion handler to run with animation finishes (default is nil)

  • SwifterSwift: Load view from nib.

    Declaration

    Swift

    public class func loadFromNib(named name: String, bundle: Bundle? = nil) -> UIView?

    Parameters

    name

    nib name.

    bundle

    bundle of nib (default is nil).

    Return Value

    optional UIView (if applicable).

  • SwifterSwift: Remove all subviews in view.

    Declaration

    Swift

    public func removeSubviews()
  • SwifterSwift: Remove all gesture recognizers from view.

    Declaration

    Swift

    public func removeGestureRecognizers()
  • SwifterSwift: Rotate view by angle on relative axis.

    Declaration

    Swift

    public func rotate(byAngle angle: CGFloat, ofType type: AngleUnit, animated: Bool = false, duration: TimeInterval = 1, completion: ((Bool) -> Void)? = nil)

    Parameters

    angle

    angle to rotate view by.

    type

    type of the rotation angle.

    animated

    set true to animate rotation (default is true).

    duration

    animation duration in seconds (default is 1 second).

    completion

    optional completion handler to run with animation finishes (default is nil).

  • SwifterSwift: Rotate view to angle on fixed axis.

    Declaration

    Swift

    public func rotate(toAngle angle: CGFloat, ofType type: AngleUnit, animated: Bool = false, duration: TimeInterval = 1, completion: ((Bool) -> Void)? = nil)

    Parameters

    angle

    angle to rotate view to.

    type

    type of the rotation angle.

    animated

    set true to animate rotation (default is false).

    duration

    animation duration in seconds (default is 1 second).

    completion

    optional completion handler to run with animation finishes (default is nil).

  • SwifterSwift: Scale view by offset.

    Declaration

    Swift

    public func scale(by offset: CGPoint, animated: Bool = false, duration: TimeInterval = 1, completion: ((Bool) -> Void)? = nil)

    Parameters

    offset

    scale offset

    animated

    set true to animate scaling (default is false).

    duration

    animation duration in seconds (default is 1 second).

    completion

    optional completion handler to run with animation finishes (default is nil).

  • SwifterSwift: Shake view.

    Declaration

    Swift

    public func shake(direction: ShakeDirection = .horizontal, duration: TimeInterval = 1, animationType: ShakeAnimationType = .easeOut, completion:(() -> Void)? = nil)

    Parameters

    direction

    shake direction (horizontal or vertical), (default is .horizontal)

    duration

    animation duration in seconds (default is 1 second).

    animationType

    shake animation type (default is .easeOut).

    completion

    optional completion handler to run with animation finishes (default is nil).

  • SwifterSwift: Add Visual Format constraints.

    Declaration

    Swift

    @available(iOS 9, *)
    public func addConstraints(withFormat: String, views: UIView...)

    Parameters

    withFormat

    visual Format language

    views

    array of views which will be accessed starting with index 0 (example: [v0], [v1], [v2]..)

  • SwifterSwift: Anchor all sides of the view into it’s superview.

    Declaration

    Swift

    @available(iOS 9, *)
    public func fillToSuperview()
  • SwifterSwift: Add anchors from any side of the current view into the specified anchors and returns the newly added constraints.

    Declaration

    Swift

    @available(iOS 9, *)
    @discardableResult
    public func anchor(
    	top: NSLayoutYAxisAnchor? = nil,
    	left: NSLayoutXAxisAnchor? = nil,
    	bottom: NSLayoutYAxisAnchor? = nil,
    	right: NSLayoutXAxisAnchor? = nil,
    	topConstant: CGFloat = 0,
    	leftConstant: CGFloat = 0,
    	bottomConstant: CGFloat = 0,
    	rightConstant: CGFloat = 0,
    	widthConstant: CGFloat = 0,
    	heightConstant: CGFloat = 0) -> [NSLayoutConstraint]

    Parameters

    top

    current view’s top anchor will be anchored into the specified anchor

    left

    current view’s left anchor will be anchored into the specified anchor

    bottom

    current view’s bottom anchor will be anchored into the specified anchor

    right

    current view’s right anchor will be anchored into the specified anchor

    topConstant

    current view’s top anchor margin

    leftConstant

    current view’s left anchor margin

    bottomConstant

    current view’s bottom anchor margin

    rightConstant

    current view’s right anchor margin

    widthConstant

    current view’s width

    heightConstant

    current view’s height

    Return Value

    array of newly added constraints (if applicable).

  • SwifterSwift: Anchor center X into current view’s superview with a constant margin value.

    Declaration

    Swift

    @available(iOS 9, *)
    public func anchorCenterXToSuperview(constant: CGFloat = 0)

    Parameters

    constant

    constant of the anchor constraint (default is 0).

  • SwifterSwift: Anchor center Y into current view’s superview with a constant margin value.

    Declaration

    Swift

    @available(iOS 9, *)
    public func anchorCenterYToSuperview(constant: CGFloat = 0)

    Parameters

    withConstant

    constant of the anchor constraint (default is 0).

  • SwifterSwift: Anchor center X and Y into current view’s superview

    Declaration

    Swift

    @available(iOS 9, *)
    public func anchorCenterSuperview()