2017-12-29《水波(波纹)涟漪效果》

水波(波纹)涟漪效果

func doRippleEffectAnimation() {
    transitionWithType(name:"doRippleEffectAnimation" ,type: "rippleEffect", subtype: kCATransitionFade, duration: 1.75, forView: yourView)
}

func transitionWithType(name:String ,type:String ,subtype:String? ,duration:TimeInterval ,forView:UIView) {
    let animation = CATransition()
    animation.duration = duration
    animation.type = "rippleEffect"
    if (subtype != nil) {
        animation.subtype = kCATransitionFade
    }
    animation.timingFunction =  CAMediaTimingFunction(name: kCAMediaTimingFunctionLinear)
    forView.layer.add(animation, forKey: name)
}

参考:https://github.com/lizelu/CATransitionDemo

你可能感兴趣的:(2017-12-29《水波(波纹)涟漪效果》)