/*
一般来说,改变按钮的位置,缩放大小与旋转角度可以采用:
bounds:改变其宽长,以致改变其大小
center:改变其中心点,以改变其位置
transform:即可以改变其位置,缩放大小与旋转角度
而frame常用于控件初始化,其他应用比较少。
*/
//位置移动
- (IBAction)move:(UIButton *) button {
int tx = 0,ty = 0;
if (button.tag == 10 || button.tag == 12) {
ty = (button.tag == 10)? -20:20;
}else{
tx = (button.tag == 11)? -20:20;
}
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:0.5];
self.iconP.transform = CGAffineTransformTranslate(self.iconP.transform,tx,ty);
[UIView commitAnimations];
}
//缩放大小
- (IBAction)zoon:(UIButton *)button {
float sx = 0,sy = 0;
button.tag?(sx = 1.2,sy = 1.2):(sx = 0.8,sy = 0.8);
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:0.5];
self.iconP.transform = CGAffineTransformScale(self.iconP.transform, sx, sy);
[UIView commitAnimations];
}
//旋转角度
-(IBAction)rotate:(UIButton *)button{
int rotate = 0;
button.tag? (rotate = 1):(rotate = -1);
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:0.5];
self.iconP.transform = CGAffineTransformRotate(self.iconP.transform, M_PI_4*rotate);
[UIView commitAnimations];
}