iOS学习之动画效果的实现
//
// ViewController.m
// UI-动画练习
//
// Created by jzq_mac on 15/7/22.
// Copyright (c) 2015年 jzq_mac. All rights reserved.
//
#import
"ViewController.h"
@interface
ViewController ()
{
UIImageView *animation;
UIView *view;
UIView *view1;
}
@end
@implementation ViewController
- (void)viewDidLoad {
[super
viewDidLoad];
[self
creatView];
[NSTimer
scheduledTimerWithTimeInterval
target:self
selector:@selector(creatView)
userInfo:nil
repeats:YES];
}
- (void)creatView
{
//动态图并移动动态图
animation = [[UIImageView
alloc,
,
)];
animation.layer.cornerRadius =
;
animation.layer.masksToBounds =
YES;
NSMutableArray *list = [NSMutableArray
array];
for (int i =
; i <= ; i++) {
NSString *name = [NSString
stringWithFormat:@"动态猫-%d(被拖移).tiff",i];
[list
addObject:[UIImage
imageNamed:name]];
}
animation.animationImages = list;
animation.animationDuration =
;
;
[animation
startAnimating];
[UIView
animateWithDuration
animations:^{animation.frame =
CGRectMake,
,
);}
completion:^(BOOL finishied){[UIView
animateWithDuration
animations:^{animation.frame =
CGRectMake,
);}];}];
[self.view
addSubview:animation];
// 移动视图
self.view.backgroundColor = [UIColor
grayColor];
view =[[UIView
alloc,
,
)];
view.backgroundColor = [UIColor
redColor];
view.layer.cornerRadius =
;
[self.view
addSubview:view];
[UIView
animateWithDuration
animations:^{view.frame =
CGRectMake,
,
);}
completion:^(BOOL finished){[UIView
animateWithDuration
animations:^{view.frame =
CGRectMake,
,
);}];}];
view.alpha =
;
[UIView
animateWithDuration
animations:^{view.alpha =
;}];
view1 =[[UIView
alloc,
,
)];
view1.backgroundColor = [UIColor
yellowColor];
view1.layer.cornerRadius =
;
[self.view
addSubview:view1];
view1.alpha =
;
[UIView
animateWithDuration
animations:^{view1.alpha =
;}];
[UIView
animateWithDuration
animations:^{view1.frame =
CGRectMake,
,
);}
completion:^(BOOL finished){[UIView
animateWithDuration
animations:^{view1.frame =
CGRectMake,
,
);}];}];
}
//- (void)click:(UIButton *)sender
//{
// if (sender.selected !=YES ) {
// sender.selected = YES;
// [animation startAnimating];
// [sender setTitle:@"開始" forState:UIControlStateNormal];
//
// }else{
// sender.selected = NO;
// [animation stopAnimating];
// [sender setTitle:@"暂停" forState:UIControlStateSelected];
// }
//}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
@end
最新文章
- Linux &; Systemd 挂载问题解决
- Github 新的项目管理模式——Projects
- python file 文件读写
- CAST和CONVERT差别与联系
- form表单中的enctype属性什么意思?
- Spring事务管理中@Transactional的propagation参数
- 如何调用EcStore中的API接口
- C语言库函数大全及应用实例五
- sns社交系统ThinkSNS+ 更新至V0.8.2,新增圈子功能
- MongoDB基础介绍安装与使用
- mysql字符设置
- 201621123068 Week02-Java基本语法与类库
- RENAME方法进行分区改造
- 如何使用Android Studio把自己的Android library分享到jCenter和Maven Central
- poj1733(带权并查集+离散化)
- ES6 Proxy的应用场景
- python判断结构总结
- 浏览器是怎样工作的:渲染引擎,HTML解析
- 通过ffplay实现摄像头preview
- attr全选第三次失效