private func transitionWithType(type:String,withSubType subType:String,forView view:UIView){
//创建CATransition对象
letanimation =CATransition()
//设置运动时间
animation.duration=1
//设置运动type
animation.type= type;
if(!subType.isEmpty) {
//设置子类
animation.subtype= subType;
}
//设置运动速度
animation.timingFunction=CAMediaTimingFunction(name:kCAMediaTimingFunctionEaseInEaseOut)
view.layer.addAnimation(animation, forKey:"animation")
}
源码 https://github.com/itroad-l/YLTransitionAnimation.git