for循环创建4*4个view,然后对立面的所有view进行动画,这里列集中动画的效果:
1,旋转动画
for tile in backgrounds{ //现将数字块大小职位原始尺寸的1/10 tile.layer.setAffineTransform(CGAffineTransform(scaleX: 0.1,y: 0.1)) //设置动画效果,动画时间长度1秒 UIView.animate(withDuration: 1, delay: 0.01, options: [], animations: { }, completion: { (finished) in UIView.animate(withDuration: 1, animations: { //完成动画时,数字块复原 tile.layer.setAffineTransform(CGAffineTransform.identity) }) }) }
2,不透明到透明的效果
for tile in backgrounds { tile.alpha = 0 //设置动画效果,动画时间长度1秒 UIView.animate(withDuration: 1, delay: 0.01, options: [.curveEaseInOut], animations: { }, completion: { (finished) in UIView.animate(withDuration: 1, animations: { tile.alpha = 1 }) }) }
3,从小到大的效果
for tile in backgrounds { //现将数字快大小之前原始尺寸的1/10 tile.layer.setAffineTransform(CGAffineTransform(scaleX:0.1,y:0.1)) //设置动画效果,动画时间长度1秒 UIView.animate(withDuration: 1, delay: 0.01, options: [], animations: { tile.layer.setAffineTransform(CGAffineTransform(scaleX:1,y:1)) }, completion: { (finished) in UIView.animate(withDuration: 0.08, animations: { tile.layer.setAffineTransform(CGAffineTransform.identity) }) }) }
记录下三种动画效果
时间: 2024-10-16 06:35:15