放大、缩小、旋转、开始动画
来源:互联网 发布:股票数据抓取软件 编辑:程序博客网 时间:2024/05/16 11:23
AppDelegate.m
#import "AppDelegate.h"@implementation AppDelegate- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions{ self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]]; // Override point for customization after application launch. self.window.backgroundColor = [UIColor whiteColor]; [self.window makeKeyAndVisible]; _index = 0; //创建可变数组 _viewArrary = [[NSMutableArray alloc] initWithCapacity:7]; for (int i=0; i<7; i++) { //创建视图,并且设置frame值 UIView *view = [[UIView alloc] initWithFrame:CGRectMake(50, 50, 220, 220)]; <span style="color:#ff0000;"> //设置背景颜色,使用三色值(0,1)</span> view.backgroundColor = [UIColor colorWithRed:arc4random()%10*.1 green:arc4random()%10*.1 blue:arc4random()%10*.1 alpha:1]; //添加到window上显示 [self.window addSubview:view]; //取得前一个视图 UIView *lastView = [_viewArrary lastObject]; if (lastView != nil) { view.transform = CGAffineTransformScale(lastView.transform, .7, .7); } [_viewArrary addObject:view]; } //添加一个旋转按钮 UIButton *button1 = [UIButton buttonWithType:UIButtonTypeRoundedRect]; button1.frame = CGRectMake(50, 400, 50, 20); button1.tag = 101; button1.backgroundColor = [UIColor redColor]; //设置标题 [button1 setTitle:@"开始" forState:UIControlStateNormal]; //添加一个点击事件 [button1 addTarget:self action:@selector(buttonAction:) forControlEvents:UIControlEventTouchUpInside]; [self.window addSubview:button1]; //添加一个放大按钮 UIButton *button2 = [UIButton buttonWithType:UIButtonTypeRoundedRect]; button2.frame = CGRectMake(120, 400, 50, 20); button2.tag = 102; button2.backgroundColor = [UIColor redColor]; //设置标题 [button2 setTitle:@"放大" forState:UIControlStateNormal]; //添加一个点击事件 [button2 addTarget:self action:@selector(buttonAction:) forControlEvents:UIControlEventTouchUpInside]; [self.window addSubview:button2]; //添加一个缩小按钮 UIButton *button3 = [UIButton buttonWithType:UIButtonTypeRoundedRect]; button3.frame = CGRectMake(190, 400, 50, 20); button3.tag = 103; button3.backgroundColor = [UIColor redColor]; //设置标题 [button3 setTitle:@"缩小" forState:UIControlStateNormal]; //添加一个点击事件 [button3 addTarget:self action:@selector(buttonAction:) forControlEvents:UIControlEventTouchUpInside]; [self.window addSubview:button3]; return YES;}- (void)buttonAction:(UIButton *)button{ //开始旋转的按钮 if (button.tag == 101) { //开启定时器 [NSTimer scheduledTimerWithTimeInterval:1 target:self selector:@selector(timeAction:) userInfo:nil repeats:YES]; } else if (button.tag == 102) { for (UIView *view in _viewArrary) { <span style="color:#ff0000;">//放大</span> view.transform = CGAffineTransformScale(view.transform, 2, 2); } } else if (button.tag == 103) { for (UIView *view in _viewArrary) { <span style="color:#ff0000;"> //缩小</span> view.transform = CGAffineTransformScale(view.transform, .5, .5); } } }- (void)timeAction:(NSTimer *)time{ //开始动画 [UIView beginAnimations:nil context:nil]; [UIView setAnimationDuration:.5]; //遍历7个视图 for (int i=0; i<_viewArrary.count; i++) { UIView *view = [_viewArrary objectAtIndex:i]; //_viewArrary[i] //设置背景颜色 view.backgroundColor = [UIColor colorWithRed:arc4random()%10*.1 green:arc4random()%10*.1 blue:arc4random()%10*.1 alpha:1]; <span style="color:#ff0000;"> //旋转</span> view.transform = CGAffineTransformRotate(view.transform, M_PI/10); } //结束动画 [UIView commitAnimations]; _index ++; //如果到第十秒停止 if (_index == 10) { for (UIView *view in _viewArrary) { [view removeFromSuperview]; } //停止计时器 [time invalidate]; }}@end
0 0
- 放大、缩小、旋转、开始动画
- ---Transform---放大缩小旋转
- Android动画——放大、缩小、旋转、平移、组合
- 放大缩小动画
- android 旋转,放大,缩小图片
- picturebox放大、缩小、旋转、拖拽
- silverlight图片旋转、放大、缩小
- 控件移动,放大,缩小,旋转
- unity触摸放大缩小旋转
- 放大缩小容器:仿动画
- uiviewcontroller 转场放大缩小动画
- uiviewcontroller 转场放大缩小动画
- uiviewcontroller 转场放大缩小动画
- uiviewcontroller 转场放大缩小动画
- iOS 图片放大缩小动画
- Html5学习--运动且旋转并放大缩小的动画效果
- 各种效果动画操作展示(放大、缩小、旋转、翻转等)
- javascript做图片放大,缩小,旋转
- 简述防火墙--未知危险的屏障
- plsql无法连接64位oracle数据库的解决方法
- DebuggerStepThrough特性节省Debug时间
- 双击setup.exe安装时出现Unknown exception解决办法
- iOS推送现在只支持TLS了
- 放大、缩小、旋转、开始动画
- XAML布局:StackPanel、Grid、生成连连看游戏布局
- .gitignore
- SVN merge 三种方式
- 关于android中PendingIntent.getBroadcase的注册广播
- 树状数组
- 3D地形编程——之GeoMipMap基础
- HDU 4272 LianLianKan DFS+map优化
- poj解题报告——poj1006