- (void)viewDidLoad {
[super viewDidLoad];
UIButton * button=[[UIButton alloc]initWithFrame:CGRectMake(200, 50, 100, 45)];
button.backgroundColor=[UIColor redColor];
[button setTitle:@"点击" forState:UIControlStateNormal];
[button addTarget:self action:@selector(clickAction) forControlEvents:UIControlEventTouchUpInside];
[self.view addSubview:button];
view=[[UIView alloc]initWithFrame:CGRectMake(50, 50, 100, 100)];
view.backgroundColor=[UIColor yellowColor];
[self.view addSubview:view];
}
- (void)clickAction{
//仿射变换
[UIView animateWithDuration:1 animations:^{
// view.transform=CGAffineTransformMakeScale(2, 2);//缩放倍数
// view.transform=CGAffineTransformScale(view.transform, 3, 3);//在原来的基础上不停缩放
}];
[UIView animateWithDuration:1 animations:^{
// view.transform=CGAffineTransformMakeTranslation(100, 100);//移动
// view.transform=CGAffineTransformTranslate(view.transform, 100, 100);//在原来基础上移动
}];
[UIView animateWithDuration:1 animations:^{
// view.transform=CGAffineTransformMakeRotation(M_PI);//顺时针旋转180度
// view.transform=CGAffineTransformRotate(view.transform, M_PI);//在原来基础上继续顺时针旋转
// view.transform=CGAffineTransformRotate(view.transform, M_PI_2);//在原来基础上继续顺时针旋转90度
// view.transform=CGAffineTransformRotate(view.transform, -M_PI_2);//在逆时针旋转90
view.transform=CGAffineTransformRotate(view.transform, M_PI_2*180/68);//旋转角度68度
}];
}