复习这两天学习的内容
动画
// frame bounds alpha 背景颜色 center transform(转换)
UIImageView* iv =[[UIImageView alloc]initWithFrame:CGRectMake(100, 100, 100, 100)];
iv.image = [UIImage imageNamed:@"8.jpg"];
[self.view addSubview:iv];
//NO.1旋转渐变animateWithDuration(动画持续时间)
// [UIView animateWithDuration:3 animations:^{
// iv.center = CGPointMake(300, 300);
// iv.alpha = .5;
// iv.transform = CGAffineTransformScale(iv.transform, .5, .5);
// //旋转
// iv.transform =CGAffineTransformRotate(iv.transform, 90.0*M_PI/180);
// }];
//NO.2原地向左旋转 completion完成
// [UIView animateWithDuration:3 animations:^{
// iv.transform = CGAffineTransformRotate(iv.transform, 90.0*M_PI/180);
// } completion:^(BOOL finished) {
// [iv removeFromSuperview];
// }];
//NO.3 delay(延迟时间)
[UIView animateWithDuration:3 delay:3 options:UIViewAnimationOptionCurveEaseIn animations:^{
iv.center = CGPointMake(300, 300);
} completion:^(BOOL finished) {
[iv removeFromSuperview];
}];
}
//旋转,左旋
number++;
CGAffineTransform rotate = CGAffineTransformMakeRotation(number / 180.0 * M_PI );
[viewDemo setTransform:rotate];
}
如果使用此方法连续点击button就可以显示处一点一点的移动效果
每次旋转90度的话可以使用一下的代码实现效果
-(void)testViewDemo
{
//旋转,右旋
number = number+90.0;
CGAffineTransform rotate = CGAffineTransformMakeRotation(number / 180.0 * M_PI );
[viewDemo setTransform:rotate];
}
UIView实现左旋效果
//旋转,左旋
number = number-90.0;
CGAffineTransform rotate = CGAffineTransformMakeRotation(number / 180.0 * M_PI );
[viewDemo setTransform:rotate];