平移、缩放、旋转、组合
//平移
- (void)translate{
[UIView animateWithDuration:2 animations:^{
self.headerView.transform = CGAffineTransformTranslate(self.headerView.transform, 10, 10);
}];
}
//放大
-(void)scaleBig
{
//宽和高传进来的再乘以设置的比例放大
[UIView animateWithDuration:2 animations:^{
self.headerView.transform = CGAffineTransformScale(self.headerView.transform,1.2, 1.2);
}];
}
//缩小
-(void)scaleSmall
{
//宽和高传进来的再乘以设置的比例缩小
[UIView animateWithDuration:2 animations:^{
self.headerView.transform = CGAffineTransformScale(self.headerView.transform,0.8, 0.8);
}];
}
//旋转
-(void)Rotation
{
//传进来的角度再加上设置的角度旋转
[UIView animateWithDuration:2 animations:^{
self.headerView.transform = CGAffineTransformRotate(self.headerView.transform, M_PI/4);
}];
}
//平移+缩放
- (void)translationScale{
[UIView animateWithDuration:2 animations:^{
//平移x:50 y:100
CGAffineTransform t = CGAffineTransformMakeTranslation(50, 100);
self.titleLabel.transform = CGAffineTransformScale(t, 3, 5);
}];
}
//平移+旋转 组合转换
- (void)translationRotation{
[UIView animateWithDuration:2 animations:^{
//平移x:50 y:100
CGAffineTransform t = CGAffineTransformMakeTranslation(100, 100);
//t替换成self.headerView.transform,效果不同
CGAffineTransform r = CGAffineTransformRotate(t, M_PI/4);
self.headerView.transform = CGAffineTransformConcat(t, r);
}];
}
网友评论