RippleEffectView - A Neat Rippling View Effect

Overview

RippleEffectView

Not only Uber-like animated screen background.

Swift 3.0 Pod Twitter Blog

RippleEffectView inspired by RayWenderlich.com article How To Create an Uber Splash Screen

How it may looks like

Basic customization (color randomization)

rippleEffectView.tileImageRandomizationClosure = { rows, columns, row, column, image in
  let newImage = image.imageWithRenderingMode(UIImageRenderingMode.AlwaysTemplate)
  UIGraphicsBeginImageContextWithOptions(image.size, false, newImage.scale)
  UIColor.random.set()
  newImage.drawInRect(CGRectMake(0, 0, image.size.width, newImage.size.height));
  if let titledImage = UIGraphicsGetImageFromCurrentImageContext() {
    UIGraphicsEndImageContext()
    return titledImage
  }
  UIGraphicsEndImageContext()
  return image
}
rippleEffectView.magnitude = -0.6

rippleEffectView.magnitude = -0.6

rippleEffectView.magnitude = 0.2

rippleEffectView.magnitude = 0.2

Complex customization

rippleEffectView.tileImageCustomizationClosure = { rows, columns, row, column, image in
  let newImage = image.imageWithRenderingMode(UIImageRenderingMode.AlwaysTemplate)
  UIGraphicsBeginImageContextWithOptions(image.size, false, newImage.scale)
      
  let xmiddle = (columns % 2 != 0) ? columns/2 : columns/2 + 1
  let ymiddle = (rows % 2 != 0) ? rows/2 : rows/2 + 1
      
  let xoffset = abs(xmiddle - column)
  let yoffset = abs(ymiddle - row)
      
  UIColor(hue: 206/360.0, saturation: 1, brightness: 0.95, alpha: 1).colorWithAlphaComponent(1.0 - CGFloat((xoffset + yoffset)) * 0.1).set()
      
  newImage.drawInRect(CGRectMake(0, 0, image.size.width, newImage.size.height));
  if let titledImage = UIGraphicsGetImageFromCurrentImageContext() {
    UIGraphicsEndImageContext()
    return titledImage
  }
  UIGraphicsEndImageContext()
  return image
}
rippleEffectView.rippleType = .Heartbeat
rippleEffectView.magnitude = 0.2

rippleEffectView.magnitude = 0.2

Requirements

  • Swift 3.0+
  • iOS 9.3+
  • Xcode 8.0+

Installation

CocoaPods

RippleEffectView is available through CocoaPods. To install it, simply add the following line to your Podfile:

target 'Your Project' do
   use_frameworks!
   pod "RippleEffectView"
end

Manual

Copy RippleEffectView.swiftto your project, then

#Usage Add new RippleEffectView, assign tileImage and call startAnimating().

rippleEffectView = RippleEffectView()
rippleEffectView.tileImage = UIImage(named: "some image")
rippleEffectView.magnitude = 0.2
rippleEffectView.cellSize = CGSize(width:50, height:50)
rippleEffectView.rippleType = .heartbeat
view.addSubview(rippleEffectView)

NB! startAnimating doesn't work if called in viewDidLoad and viewWillAppear. Working on fix. Place startAnimating() in viewDidAppear()

Configurable properties

NB! RippleEffectView initialize itself with parent view bounds automatically, so you do not need to set it manually. If you need to use it in limited view, then use auxiliary view, e.g.

Animation uses transform, scale and opacity.

Special properties

  1. tileImage UIImage that will displayed in every title. RippleEffectView uses size of image to calculate grid size. No default value.
  2. animationDuraton. Default 3.5
  3. magnitude force that will be applied to every circle to create ripple effect. Uber-like effect is about 0.1 - 0.2. GIF example -0.8
  4. cellSize size of tile. Could be helpful if vector image used. Property is optional, if not set then tileImage size will be used.
  5. rippleType Type of ripple effect. .OneWave and .Heartbeat. Default .OneWave

##Read-only properties

  1. rows rows count
  2. columns columns count

Methods

stopAnimating Start ripple animation startAnimating Stop all animations

Manual control of the grid.

You will need this if you change tileImageRandomizationClosure. When you call renderGrid to recreate all items. If you want just remove all items (e.g. memory warning) then call removeGrid

Callbacks

Tile image customization.

You may setup image for each grid view individually, or customize one that assigned in tileImage. (See Demo project for example code)

var tileImageRandomizationClosure: RandomizationClosure? = (totalRows:Int, totalColumns:Int, currentRow:Int, currentColumn:Int, originalImage:UIImage)->(UIImage)

Animation Finished

Main purpose of this component is to create animated screen background. You may stop animation and hide a screen as soon as data available, or wait for the animation end and the show the data.

rippleEffectView.animationDidStop = { _ in 
  // do something
}
You might also like...
A Swift library to take the power of UIView.animateWithDuration(_:, animations:...) to a whole new level - layers, springs, chain-able animations and mixing view and layer animations together!
A Swift library to take the power of UIView.animateWithDuration(_:, animations:...) to a whole new level - layers, springs, chain-able animations and mixing view and layer animations together!

ver 2.0 NB! Breaking changes in 2.0 - due to a lot of requests EasyAnimation does NOT automatically install itself when imported. You need to enable i

 Garland View seamlessly transitions between multiple lists of content.
Garland View seamlessly transitions between multiple lists of content.

Garland View seamlessly transitions between multiple lists of content. We specialize in the designing and coding of custom UI for Mobile

List a collection of items in a horizontally scrolling view. A scaling factor controls the size of the items relative to the center.
List a collection of items in a horizontally scrolling view. A scaling factor controls the size of the items relative to the center.

CAROUSEL List a collection of items in a horizontally scrolling view. A scaling factor controls the size of the items relative to the center. We speci

SwiftUI animated image view that works on iOS and layout just as SwiftUI.Image

SwiftUI.AnimatedImage SwiftUI animated image view that works on iOS and layout just as SwiftUI.Image Screen.Recording.2021-07-31.at.02.18.33.mov Insta

A library of custom iOS View Controller Animations and Interactions.
A library of custom iOS View Controller Animations and Interactions.

RZTransitions is a library to help make iOS7 custom View Controller transitions slick and simple. Installation CocoaPods (Recommended) Add the followi

CCMRadarView uses the IBDesignable tools to make an easy customizable radar view with animation
CCMRadarView uses the IBDesignable tools to make an easy customizable radar view with animation

CCMRadarView CCMRadarView is a simple to use view that uses the new IBDesignable and IBInspectable features of XCode6 to easily configure the icon in

Various view's effects for iOS, written in Swift. Allows you to animate views nicely with easy to use extensions
Various view's effects for iOS, written in Swift. Allows you to animate views nicely with easy to use extensions

Various view's effects for iOS, written in Swift. Allows you to animate views nicely with easy to use extensions. Every animation is randomized. Currently supported animations:

Library for creating swipe actions for any SwiftUI View

SwipeActions Library for creating swipe actions for any SwiftUI View, similar to

MGFlipView allows to create flipping view in easy way without worrying about flipping animation and flipping logic.
MGFlipView allows to create flipping view in easy way without worrying about flipping animation and flipping logic.

MGFlipView About If you are looking for an easy way of implement 3D flipping view, you are in the right place. MGFlipView allows to create flipping vi

Comments
  • iOS Version Requirement

    iOS Version Requirement

    Hi,

    This repo looks promising but I am very hesitated to integrate this because it requires iOS 9.3+.

    As of Sept 6th, 2017, Apple says there are 11% devices running below iOS 10. I understand that we only require 9.3+ and after the iOS 11 release on Sept 12th, 2017, there will be less than 11% running below iOS 10. But having even 2-3% devices can't use this awesome repo would ba a lost.

    I am wondering why we have to require iOS 9.3+? What if the user has 9.0 and run this code? What's best practice to support iOS 9+?

    Thanks and keep up the great work!

    opened by AshleyDeng 1
Releases(1.0.2)
An easy way to add a simple, shimmering effect to any view in an iOS app.

Shimmer Shimmer is an easy way to add a shimmering effect to any view in your app. It's useful as an unobtrusive loading indicator. Shimmer was origin

Meta Archive 9.4k Dec 26, 2022
An easy way to add a shimmering effect to any view with just one line of code. It is useful as an unobtrusive loading indicator.

LoadingShimmer An easy way to add a shimmering effect to any view with just single line of code. It is useful as an unobtrusive loading indicator. Thi

Jogendra 1.4k Jan 6, 2023
Shimmer: A super-light modifier that adds a shimmering effect to any SwiftUI View

SwiftUI-Shimmer ✨ Shimmer is a super-light modifier that adds a shimmering effec

Vikram Kriplaney 389 Jan 2, 2023
🎨 Gradient animation effect like Instagram

Pastel ?? Gradient animation effect like Instagram Example override func viewDidLoad() { super.viewDidLoad() let pastelView = PastelView(fram

Cruz 3.4k Jan 1, 2023
Genie - A Playground to recreate the macOS Genie Effect.

Genie A Playground to recreate the macOS Genie Effect. For more information, please read the accompanying blog post: Recreating the macOS Genie Effect

Harshil Shah 66 Nov 18, 2022
MotionBlur allows you to add motion blur effect to iOS animations.

MotionBlur MotionBlur allows you to add motion blur effect to your animations (currently only position's change). See the accompanying blog post to le

Arek Holko 1.5k Nov 3, 2022
RetroBubbleText - A simple effect used in Retrogram which renders text with a fun bubble-style outline in SwiftUI

Retro Bubble Text This is a simple effect used in Retrogram which renders text w

Simeon Saëns 5 Aug 29, 2022
SYBlinkAnimationKit is a blink effect animation framework for iOS, written in Swift.

SYBlinkAnimationKit is a blink effect animation framework for iOS, written in Swift ?? Demo There are 5 types of animation for component. border borde

Shohei Yokoyama 126 Oct 28, 2021
Inspired by Fabric - Answers animation. Allows to "build" given view with pieces. Allows to "destroy" given view into pieces

ADPuzzleAnimation Whats inside Custom animation for UIView inspired by Fabric - Answers animation. Easy to use To create your first animation you need

Anton 126 Dec 25, 2022
ChainPageCollectionView A custom View with two level chained collection views and fancy transition animation

ChainPageCollectionView A custom View with two level chained collection views and fancy transition animation. Demo Requirements iOS 9.0+ Xcode 8 Insta

Yansong Li 775 Dec 7, 2022