动画

block动画

[UIView animateWithDuration:1.0 animations:^{

    label.alpha = 1.0;

} completion:^(BOOL finished) {

[label removeFromSupperView];

}];

首尾式动画

[UIView beginAnimations:nil context:nil];

[UIView animatewithDuration:2 {

    ...

})];

[UIView .commitAnimations()];

transform 属性

位移

// 基于对象的初始位置坐的形变

imageView.transform = CGAffineTransformMakeTranslation(0, 20);

// 基于transform参数坐的形变,世纪效果就是一个累加的位移效果

imageView.transform = CGAffineTransformTranslate(self.headImageView.transform, 0, -20);

放大缩小

imageView.transform = CGAffineTransformScale(imageView.transform, 2.0, 1.0);

旋转

// OC中所有跟角度相关的数值,都是弧度值

imageView.transform = CGAffineTransformRotate(imageView, transform, M_PI_4);

帧动画( 汤姆猫)

// 所谓帧动画就是让一组图片一张一张的顺序播放

if ([self.tom isAnimating]) return;

// 图片的数组

NSMutableArray *arrayM =  [NSMutableArray array];

for (int i=0; i<81; i++) {    

    NSString *imageView = [NSString stringWithFormat:@"drink_%02d.jpg", i];

   //  UIImage *iamge = [UIImage imageNamed: imageName]; // 图片使用后不会直接释放掉,具体释放时间由系统决定

NSString *path = [NSBundle mainBundle] pathForResource:imageName ofType:nil];

UIImage *image = [UIImage iamgeWithContentsOfFile:path];

    [arrayM addObject: image];

}

[self.tom setAnimationImages: arrayM];

[self.tom setAnimationDuration:arrayM.count * 0.075];

// 设置动画时长

[self.tom setAnimationRepeatCount: 1];

// 开始动画

[self.tom startAnimating];

// 动画完成后清除图片

[self.tom performSelector:@selector(setAnimationImages:) withObject:nil afterDelay:self.tom.animationDuration]; 

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

友情链接更多精彩内容