YRipple 1.0.0

YRipple 1.0.0

Maintained by itsjohnye.



YRipple 1.0.0

  • By
  • itsjohnye

YRipple

YRipple is a framework inherit the legacy from PIRipple.

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

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"

in your project:

import YRipple

Carthage:

(to be updated)

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.