Skip to main content
ViewAnimator provides access to all animatable properties on a UIView. Use the animator property on any UIView instance to animate its properties within a Wave animation block.

Usage

Access the animator through the animator property on any UIView:
Wave.animateWith(spring: .defaultAnimated) {
    myView.animator.center = CGPoint(x: 100, y: 100)
    myView.animator.alpha = 0.5
}

Layout properties

Properties that control the view’s position and size.
frame
CGRect
The frame of the attached UIView.
Wave.animateWith(spring: spring) {
    myView.animator.frame = CGRect(x: 0, y: 0, width: 200, height: 200)
}
bounds
CGRect
The bounds of the attached UIView.
Wave.animateWith(spring: spring) {
    myView.animator.bounds = CGRect(x: 0, y: 0, width: 200, height: 200)
}
center
CGPoint
The center of the attached UIView.
Wave.animateWith(spring: spring) {
    myView.animator.center = CGPoint(x: 100, y: 100)
}
origin
CGPoint
The origin of the attached UIView.
Wave.animateWith(spring: spring) {
    myView.animator.origin = CGPoint(x: 50, y: 50)
}

Appearance properties

Properties that control the view’s visual appearance.
backgroundColor
UIColor
The background color of the attached UIView.
Wave.animateWith(spring: spring) {
    myView.animator.backgroundColor = .systemBlue
}
alpha
CGFloat
The alpha of the attached UIView.
Wave.animateWith(spring: spring) {
    myView.animator.alpha = 0.5
}
cornerRadius
CGFloat
The corner radius of the attached UIView’s layer. This is a convenience API that forwards to the CALayer’s animator.
Wave.animateWith(spring: spring) {
    myView.animator.cornerRadius = 12.0
}

Border properties

Properties that control the view’s border appearance. These are convenience APIs that forward to the CALayer’s animator.
borderColor
UIColor
The border color of the attached UIView’s layer.
Wave.animateWith(spring: spring) {
    myView.animator.borderColor = .systemRed
    myView.animator.borderWidth = 2.0
}
borderWidth
CGFloat
The border width of the attached UIView’s layer.
Wave.animateWith(spring: spring) {
    myView.animator.borderWidth = 3.0
}

Shadow properties

Properties that control the view’s shadow appearance. These are convenience APIs that forward to the CALayer’s animator.
shadowColor
UIColor
The shadow color of the attached UIView’s layer.
Wave.animateWith(spring: spring) {
    myView.animator.shadowColor = .black
    myView.animator.shadowOpacity = 0.3
}
shadowOpacity
CGFloat
The shadow opacity of the attached UIView’s layer.
Wave.animateWith(spring: spring) {
    myView.animator.shadowOpacity = 0.5
}
shadowOffset
CGSize
The shadow offset of the attached UIView’s layer.
Wave.animateWith(spring: spring) {
    myView.animator.shadowOffset = CGSize(width: 0, height: 4)
}
shadowRadius
CGFloat
The shadow radius of the attached UIView’s layer.
Wave.animateWith(spring: spring) {
    myView.animator.shadowRadius = 8.0
}

Transform properties

Properties that control the view’s affine transform.
scale
CGPoint
The affine scale transform of the attached UIView’s layer.
Wave.animateWith(spring: spring) {
    myView.animator.scale = CGPoint(x: 1.5, y: 1.5)
}
translation
CGPoint
The affine translation transform of the attached UIView’s layer.
Wave.animateWith(spring: spring) {
    myView.animator.translation = CGPoint(x: 50, y: 100)
}

Complete example

import Wave
import UIKit

class ViewController: UIViewController {
    let myView = UIView()
    
    func animateView() {
        Wave.animateWith(spring: .defaultAnimated) {
            // Layout
            myView.animator.center = CGPoint(x: 200, y: 200)
            
            // Appearance
            myView.animator.backgroundColor = .systemBlue
            myView.animator.alpha = 0.8
            myView.animator.cornerRadius = 20.0
            
            // Border
            myView.animator.borderColor = .white
            myView.animator.borderWidth = 2.0
            
            // Shadow
            myView.animator.shadowColor = .black
            myView.animator.shadowOpacity = 0.3
            myView.animator.shadowOffset = CGSize(width: 0, height: 4)
            myView.animator.shadowRadius = 8.0
            
            // Transform
            myView.animator.scale = CGPoint(x: 1.2, y: 1.2)
        }
    }
}

Platform availability

iOS only. For cross-platform layer animations, use LayerAnimator.

Build docs developers (and LLMs) love