@import url(http://i.cnblogs.com/Load.ashx?type=style&file=SyntaxHighlighter.css);@import url(/css/cuteeditor.css);
@import url(http://i.cnblogs.com/Load.ashx?type=style&file=SyntaxHighlighter.css);@import url(/css/cuteeditor.css);
@import url(http://i.cnblogs.com/Load.ashx?type=style&file=SyntaxHighlighter.css);@import url(/css/cuteeditor.css);
@import url(http://i.cnblogs.com/Load.ashx?type=style&file=SyntaxHighlighter.css);@import url(/css/cuteeditor.css);
方法一:头尾式动画
- (IBAction)moveClick:(UIButton *) sender
{
CGPoint center = self.head.center;
switch (sender.tag)
{
case 1:
center.y -= 10;
break;
case 2:
center.x += 10;
break;
case 3:
center.y += 10;
break;
case 4:
center.x -= 10;
break;
default:
break;
}
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:1];
self.head.center = center;
[UIView commitAnimations];
}
方法二:通过block实现动画
- (IBAction)moveClick:(UIButton *) sender
{
CGPoint center = self.head.center;
switch (sender.tag)
{
case 1:
center.y -= 10;
break;
case 2:
center.x += 10;
break;
case 3:
center.y += 10;
break;
case 4:
center.x -= 10;
break;
default:
break;
}
[UIView animateWithDuration:1 animations:^{self.head.center = center;}];
}
总结:
self.head.transform = CGAffineTransformTranslate(self.head.transform, 0, 20);//平移
self.head.transform = CGAffineTransformScale(self.head.transform, 1.2, 1.2);//缩放
self.head.transform = CGAffineTransformRotate(self.head.transform, -M_PI_4);//旋转