PIRipple 1.1.0

PIRipple 1.1.0

测试已测试
语言语言 SwiftSwift
许可协议 MIT
发布最后发布2015年8月
SPM支持 SPM

pixelink 维护。



PIRipple 1.1.0

PIRipple

iOS (Swift) 的水波纹效果


demo

demo

  • 如果尝试此demo。git克隆/下载并打开项目,然后运行。


安装

  • 手动
    • 将 PIRipple.swift 添加到您的项目中

  • cocoapods
    • 在您的 Podfile 中添加“pod ‘PIRipple’,'1.1.0’”
    • 将“导入 PIRipple”添加到您的代码中

基本用法

UIVisualEffectView 扩展

UIView.rippleBorder(CGPoint, color: UIColor)
UIView.rippleFill(CGPoint, color: UIColor)

“CGPoint”意味着视图中的位置

  • 示例
override func touchesBegan(touches: Set<NSObject>, withEvent event: UIEvent) {
  super.touchesBegan(touches, withEvent: event)
  for touch: AnyObject in touches {
    var t: UITouch = touch as! UITouch
    let location = t.locationInView(self)

    rippleBorder(location, color: UIColor.whiteColor())

  }
}
  • 动画后运行您的代码
rippleBorder(location, color: UIColor.whiteColor()) {
  println("animation completed")
  // your code
}

类方法

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

Ripple.fill(view:UIView, locationInView or absolutePosition:CGPoint, color:UIColor)
  • locationInView

    • CGPointZero 是 UIView 中的顶部和左侧。

  • absolutePosition

    • CGPointZero 是 UIWindow 中的顶部和左侧。

  • 示例

Ripple.border(self.view, locationInView:CGPointZero, color:UIColor.whiteColor())

  • 动画后运行您的代码
Ripple.border(tagetView, locationInView:CGPointZero, color: UIColor.whiteColor()) {
  println("animation completed")
  // your code
}

高级用法

  • 配置动画
var option = Ripple.option()
//configure
option.borderWidth = CGFloat(5.0)
option.radius = CGFloat(30.0)
option.duration = CFTimeInterval(0.4)
option.borderColor = UIColor.whiteColor()
option.fillColor = UIColor.clearColor()
option.scale = CGFloat(3.0)

Ripple.run(self, locationInView: CGPointZero, option: option){
  println("animation completed")
}

  • 取消动画
UIView.rippleStop()
Ripple.stop(self.view)