Discover the power of iOS animations with UIKit! Elevate your app’s user experience by incorporating captivating animations on views, tableview, and collectionview. Explore the magic of iOS animations techniques to enhance your app’s visual appeal and engagement.

TableView Animation – it’s like adding a touch of magic to your app’s list of items! With TableView iOS Animations, you can make your rows slide in, fade out, or do other cool tricks. It’s a neat way to make your app look lively and keep your users interested as they scroll through their content!

CollectionView Animation – it’s like giving your app’s grid or gallery a little extra pizzazz! With CollectionView iOS Animation, you can make your images or items dance, fade, or even bounce onto the screen. It’s a fun way to add some flair to your app and make browsing through content a delightful experience!

ViewAnimator is a Swift library that simplifies the process of adding animations to your iOS app’s views.

With ViewAnimator, you can easily incorporate various iOS animations to make your app more dynamic and visually appealing. The library provides a straightforward API for animating views with predefined effects, allowing you to create engaging transitions and movements.

If you’re working on an iOS project and want to enhance your user interface with smooth and eye-catching iOS animations, exploring and using the ViewAnimator library could be a helpful resource. Check out the documentation and examples in the repository to get started.

iOS Animations On Views, Tableview , Collectionview With UIKit

ViewAnimator brings your UI to life with just one line

View Animation UITableView Animation UICollectionView Animation

Installation

CocoaPods

ViewAnimator is available through CocoaPods. To install it, simply add the following line to your Podfile:pod “ViewAnimator”

Manual

Drop the swift files inside of ViewAnimator/Classes into your project.

Carthage

github "marcosgriselli/ViewAnimator"

Usage

ViewAnimator provides a set of UIView extensions to easily add custom animations to your views. From version 2.0.0 there are two ways to use this extension.

Self animating views

Views can animate theirselves calling .animate(animations: [Animation]) that’s the most basic usage. Here’s the full method that contains many default arguments:

func animate(animations: [Animation],
             reversed: Bool = false,
             initialAlpha: CGFloat = 0.0,
             finalAlpha: CGFloat = 1.0,
             delay: Double = 0,
             duration: TimeInterval = ViewAnimatorConfig.duration,
             usingSpringWithDamping dampingRatio: CGFloat = ViewAnimatorConfig.springDampingRatio,
             initialSpringVelocity velocity: CGFloat = ViewAnimatorConfig.initialSpringVelocity,
             completion: (() -> Void)? = nil)

Animating multiple views

ViewAnimator follows the UIKit animations API style with a static method  UIView.animate(views: [UIView], animations: [Animation]). This makes the library really easy to use and extensible to any kind of view. As the previous example, the method contains a lot of default arguments:

static func animate(views: [UIView],
                    animations: [Animation],
                    reversed: Bool = false,
                    initialAlpha: CGFloat = 0.0,
                    finalAlpha: CGFloat = 1.0,
                    delay: Double = 0,
                    animationInterval: TimeInterval = 0.05,
                    duration: TimeInterval = ViewAnimatorConfig.duration,
                    usingSpringWithDamping dampingRatio: CGFloat = ViewAnimatorConfig.springDampingRatio,
                    initialSpringVelocity velocity: CGFloat = ViewAnimatorConfig.initialSpringVelocity,
                    completion: (() -> Void)? = nil)

AnimationType

Direction

Direction provides the axis where the animation should take place and its movement direction.

let animation = AnimationType.from(direction: .top, offset: 30.0)
view.animate(animations: [animation])

Zoom

Zoom in and Zoom out animation support.

let animation = AnimationType.zoom(scale: 0.5)
view.animate(animations: [animation])

Combined Animations

You can combine conformances of Animation to apply multiple transforms on your animation block.

let fromAnimation = AnimationType.from(direction: .right, offset: 30.0)
let zoomAnimation = AnimationType.zoom(scale: 0.2)
let rotateAnimation = AnimationType.rotate(angle: CGFloat.pi/6)
UIView.animate(views: collectionView.visibleCells,
               animations: [zoomAnimation, rotateAnimation],
               duration: 0.5)
UIView.animate(views: tableView.visibleCells,
               animations: [fromAnimation, zoomAnimation], 
               delay: 0.5)

Animation

Animation protocol provides you the posibility of expanding the animations supported by ViewAnimator with exception of the animateRandom function.

public protocol Animation {
    var initialTransform: CGAffineTransform { get }
}

UITableView/UICollection extensions

ViewAnimator comes with a set of handy extensions to make your animations in UITableView and UICollectionView a lot simpler. They both have access to cells in a section to animate easily.

They both expose a method visibleCells(in section: Int) that returns an array of UITableViewCell or UICollectionViewCell.

let cells = tableView.visibleCells(in: 1)
UIView.animate(views: cells, animations: [rotateAnimation, fadeAnimation])

Project Details

Requirements

  • Swift 4.0
  • Xcode 7.0+
  • iOS 8.0+

Github – iOS animations

Related Posts

Leave a Reply

Your email address will not be published. Required fields are marked *