Fork me on GitHub

Alex Rupérez

Link: http://j.mp/2UN4JFF
Published: 29 Apr 14:19
I starred itsjohnye/YRipple at GitHub.
iOS Ripple Effect, Xcode10 and Swift5 available
View on GitHub


View README


YRipple

Swift Version Releases Cocoapods GitHub license

YRipple is a framework inherit the legacy from PIRipple.

Now it has been updated to Xcode 10 and Swift 5.

Demo

For more details see Demo project.

Table of Contents

Installation

Manually:

Simply drop YRipple.swift from "Source" folder into your project (make sure to enable "Copy items if needed" and "Create groups").

Cocoapods:

to the Podfile:

"pod YRipple", "~>1.0.0"

then:

$ pod install

in your project:

import YRipple

Useage

UIView-extention

UIView.rippleBorder(location: yourLocation, color: UIColor)
UIView.rippleFill(location: yourLocation, color: UIColor)
for example
override func touchesBegan(_ touches: Set<UITouch>, with event: UIEvent?) {
       super.touchesBegan(touches, with: event)
       for touch: AnyObject in touches {
           let t: UITouch = touch as! UITouch
           let location = t.location(in: self)

           //RIPPLE BORDER
           rippleBorder(location:location, color: UIColor.white)       
       }

run your code after animation

rippleBorder(location:location, color: UIColor.white){
  print("animation completed")
  // add your code here
}

Class-method

YRipple.border(view:UIView, locationInView or absolutePosition:CGPoint, color:UIColor)
YRipple.fill(view:UIView, locationInView or absolutePosition:CGPoint, color:UIColor)

notably:

  • locationInView: CGPoint.Zero is top & left in UIView.
  • absolutePosition: CGPoint.Zero is top & left in UIWindow.
for example
YRipple.border(view:self.view, locationInView:CGPoint.Zero, color:UIColor.white)

run your code after animation

YRipple.border(view:tagetView, locationInView:CGPoint.Zero, color:UIColor.white) {
  print("animation completed")
  //add your code here
}

Customizing

example properties
var option = YRipple.Option()       //mind the capital form

//configuration
option.borderWidth = CGFloat(5.0)
option.radius = CGFloat(30.0)
option.duration = CFTimeInterval(0.4)
option.borderColor = UIColor.white
option.fillColor = UIColor.clear
option.scale = CGFloat(3.0)

YRipple.run(view:self.view, locationInView: CGPoint.Zero, option: option){
  print("animation completed")
  //add your code here
}

//cancel animation
UIView.rippleStop()
YRipple.stop(self.view)

License

YRipple is published under the MIT license. Copyright (c) 2018 itsjohnye.