错误的写法
self.iconView.frame.origin.y-=10
应该这样写:
CGRect temp=self.iconView.frame;
temp.origin.y-=10;
self.iconView.frame=temp;
- (IBAction)move:(UIButton *)sender {
NSInteger tag=sender.tag;
//1.,先使用临时变量进行存储
CGRect temp=self.iconView.frame;
//2.修改坐标
if(tag==1) //向左移
{
temp.origin.x-=10;
}
else if (tag==2)
{
temp.origin.y+=10;
}
else if(tag==3)
{
temp.origin.x+=10;
}
//3.重新赋值给iconView
self.iconView.frame=temp;
}
- (IBAction)boundsBig {
CGRect temp=self.iconView.bounds;
//不要使用bounds/来进行控件的坐标值的修改
//temp.origin.y-=10;
temp.size.width+=10;
temp.size.height+=10;
//以中心点做为参照
self.iconView.bounds=temp;
}
- (IBAction)centerMove {
CGPoint temp= self.iconView.center;
temp.y+=10;
self.iconView.center=temp;
}
self.iconView.transform=CGAffineTransformTranslate(self.iconView.transform, 10, 0);
self.iconView.transform=CGAffineTransformScale(self.iconView.transform, 0.9, 0.9);
//开启动画
[UIView beginAnimations:nil context:nil];
//设置动画的播放时间 以秒做为单位的
[UIView setAnimationDuration:3];
self.iconView.transform=CGAffineTransformRotate(self.iconView.transform, M_PI_2);
//提交动画--动画完成
[UIView commitAnimations];
[UIView animateWithDuration:1 animations:^{
self.iconView.transform=CGAffineTransformRotate(self.iconView.transform, M_PI_2);
}];
- (IBAction)tansformRotate {
//循环旋转
[UIView animateWithDuration:0.3 animations:^{
//设置匀速旋转
[UIView setAnimationCurve:UIViewAnimationCurveLinear];
self.iconView.transform=CGAffineTransformRotate(self.iconView.transform, M_PI_2);
} completion:^(BOOL finished) {
[self tansformRotate];
}];
}