YRipple 1.0.0

YRipple 1.0.0

itsjohnye 维护。



YRipple 1.0.0

  • 作者
  • itsjohnye

YRipple

YRipple 是一个继承自 PIRipple 的框架。

现在它已经更新到 Xcode 10 和 Swift 4.2。

演示

更多详情请参阅 演示 项目。

目录

安装

手动

简单地将 "Source" 文件夹中的 YRipple.swift 拖到项目中(确保启用“需要时复制项”和“创建组”)。

插件Cocoapods

添加到Podfile文件中

"pod YRipple", "1.0"

到您的项目

导入YRipple模块

插件Carthage

(待更新)

用法

UIView扩展

UIview.rippleBorder(location: yourLocation, color: UIColor)
UIview.rippleFill(location: yourLocation, color: UIColor)
例如
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)       
       }

动画执行后运行代码

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

类方法

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

值得注意的是

  • locationInView: CGPoint.Zero 在UIView中为顶部与左侧。
  • absolutePosition: CGPoint.Zero 在UIWindow中为顶部与左侧。
例如
YRipple.border(view:self.view, locationInView:CGPoint.Zero, color:UIColor.white)

动画执行后运行代码

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

自定义

示例属性
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)

许可证

YRipple以MIT许可证发布。