设置视图对象的transform属性,可以实现各种动画效果。
1,移动
指在同一平面内,将控件按照某个直线方向平移一定的距离。
1
2
3
4
5
|
self .imageView.transform = CGAffineTransformTranslate ( self .imageView.transform, -2.1, -2.1)
self .imageView.transform = CGAffineTransformMakeTranslation (2.3, 2.3)
|
2,旋转
1
2
3
4
5
6
7
8
|
UIView .beginAnimations( nil , context: nil )
UIView .setAnimationDuration(3.0)
self .imageView.transform = CGAffineTransformRotate ( self .imageView.transform, CGFloat (- M_PI /2))
UIView .commitAnimations()
self .imageView.transform = CGAffineTransformMakeRotation ( CGFloat (- M_PI /4))
|
3,缩放
1
2
3
4
5
6
7
8
|
UIView .beginAnimations( nil , context: nil )
UIView .setAnimationDuration(3.0)
self .imageView.transform = CGAffineTransformScale ( self .imageView.transform, 1.5 ,1.5)
UIView .commitAnimations()
self .imageView.transform = CGAffineTransformMakeScale (1.3, 1.3)
|
4,反转
1
2
3
4
5
6
7
8
9
10
11
12
|
self .imageView.transform = CGAffineTransformIdentity
UIView .beginAnimations( nil , context: nil )
UIView .setAnimationDuration(3.0)
self .imageView.transform = CGAffineTransformConcat ( self .imageView.transform,
CGAffineTransformInvert ( self .imageView.transform))
UIView .commitAnimations()
self .imageView.transform = CGAffineTransformInvert ( self .imageView.transform)
|
|
请发表评论