亚洲香蕉成人av网站在线观看_欧美精品成人91久久久久久久_久久久久久久久久久亚洲_热久久视久久精品18亚洲精品_国产精自产拍久久久久久_亚洲色图国产精品_91精品国产网站_中文字幕欧美日韩精品_国产精品久久久久久亚洲调教_国产精品久久一区_性夜试看影院91社区_97在线观看视频国产_68精品久久久久久欧美_欧美精品在线观看_国产精品一区二区久久精品_欧美老女人bb

首頁 > 學院 > 開發設計 > 正文

UIView動畫設置

2019-11-14 19:17:08
字體:
來源:轉載
供稿:網友
創建一個紅綠燈,紅、綠每5秒變化一次顏色,要求變亮的燈(色塊)面積也要同時變大。黃燈閃亮3秒鐘(0.9秒亮黃,0.1秒亮黑),點擊按鈕開始執行。
//AppDelegate.h#import <UIKit/UIKit.h>@interface AppDelegate : UIResponder <UIapplicationDelegate>@PRoperty (strong, nonatomic) UIWindow *window;@end
//AppDelegate.m//  AppDelegate.m//  traffic light////  Created by apple on 15/4/9.//  Copyright (c) 2015年 hecheng. All rights reserved.//#import "AppDelegate.h"@interface AppDelegate (){    UIView *_redView;    UIView *_greenView;    UIView *_yellowView;    CGFloat x;    CGFloat y;    }@end@implementation AppDelegate- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {        //計算屏幕尺寸    UIScreen *screens=[UIScreen mainScreen];    CGRect rect=screens.bounds;        //計算屏幕中心位置    x=rect.size.width/2;    y=rect.size.height/2;    self.window=[[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds] ;    self.window.backgroundColor=[UIColor whiteColor];    [self.window makeKeyAndVisible];        //設置紅燈,初始化顏色為黑色    _redView=[[UIView alloc] initWithFrame:CGRectMake(0, 0, 50, 50)];    _redView.backgroundColor=[UIColor blackColor];    [self.window addSubview:_redView];    _redView.center=CGPointMake(x-100, y);        //設置綠燈,初始化顏色為黑色    _greenView=[[UIView alloc] initWithFrame:CGRectMake(0, 0, 50, 50)];    _greenView.backgroundColor=[UIColor blackColor];    [self.window addSubview:_greenView];    _greenView.center=CGPointMake(x, y);        //設置黃燈,初始化顏色為黑色    _yellowView=[[UIView alloc] initWithFrame:CGRectMake(0, 0, 50, 50)];    _yellowView.backgroundColor=[UIColor blackColor];    [self.window addSubview:_yellowView];    _yellowView.center=CGPointMake(x+100, y);        //設置按鈕    UIButton *btn=[UIButton buttonWithType:UIButtonTypeSystem];    [btn setTitle:@"啟動" forState:UIControlStateNormal];    btn.frame=CGRectMake(0, 0, 50, 50);    btn.center=CGPointMake(x, y-80);    [btn addTarget:self action:@selector(didClicked) forControlEvents:UIControlEventTouchUpInside];    btn.backgroundColor=[UIColor blackColor];    [self.window addSubview:btn];    return YES;    }- (void)animationWillStart:(NSString *)animationID context:(void *)context {    NSLog(@"%@", animationID);    NSLog(@"%s", __func__);}- (void)animationDidStop:(NSString *)animationID finished:(NSNumber *)finished context:(void *)context {    if ([animationID isEqualToString:@"red"]) {        [UIView beginAnimations:@"green" context:NULL];        [UIView setAnimationDelay:5];        _redView.bounds=CGRectMake(0, 0, 50, 50);        _greenView.bounds=CGRectMake(0, 0, 100, 100);        _greenView.backgroundColor=[UIColor greenColor];        _redView.backgroundColor=[UIColor blackColor];        [UIView setAnimationDelegate:self];        [UIView setAnimationWillStartSelector:@selector(animationWillStart:context:)];        [UIView setAnimationDidStopSelector:@selector(animationDidStop:finished:context:)];        [UIView commitAnimations];    }    else if ([animationID isEqualToString:@"green"]) {        [UIView beginAnimations:@"yellow" context:NULL];        [UIView setAnimationDelay:5];        _greenView.bounds=CGRectMake(0, 0, 50, 50);        _yellowView.bounds=CGRectMake(0, 0, 100, 100);        _greenView.backgroundColor=[UIColor blackColor];        _yellowView.backgroundColor=[UIColor yellowColor];        [UIView setAnimationDelegate:self];        [UIView setAnimationWillStartSelector:@selector(animationWillStart:context:)];        [UIView setAnimationDidStopSelector:@selector(animationDidStop:finished:context:)];        [UIView commitAnimations];            }    else if ([animationID isEqualToString:@"yellow"]) {        [UIView beginAnimations:@"black1" context:NULL];        [UIView setAnimationDelay:0.9];                _yellowView.backgroundColor=[UIColor blackColor];        [UIView setAnimationDelegate:self];        [UIView setAnimationWillStartSelector:@selector(animationWillStart:context:)];        [UIView setAnimationDidStopSelector:@selector(animationDidStop:finished:context:)];        [UIView commitAnimations];    }    else if ([animationID isEqualToString:@"black1"]) {        [UIView beginAnimations:@"yellow1" context:NULL];        [UIView setAnimationDelay:0.1];                _yellowView.backgroundColor=[UIColor yellowColor];        [UIView setAnimationDelegate:self];        [UIView setAnimationWillStartSelector:@selector(animationWillStart:context:)];        [UIView setAnimationDidStopSelector:@selector(animationDidStop:finished:context:)];        [UIView commitAnimations];    }    else if ([animationID isEqualToString:@"yellow1"]) {        [UIView beginAnimations:@"black2" context:NULL];        [UIView setAnimationDelay:0.9];        _yellowView.backgroundColor=[UIColor blackColor];        [UIView setAnimationDelegate:self];        [UIView setAnimationWillStartSelector:@selector(animationWillStart:context:)];        [UIView setAnimationDidStopSelector:@selector(animationDidStop:finished:context:)];        [UIView commitAnimations];    }    else if ([animationID isEqualToString:@"black2"]) {        [UIView beginAnimations:@"yellow2" context:NULL];        [UIView setAnimationDelay:0.1];                _yellowView.backgroundColor=[UIColor yellowColor];        [UIView setAnimationDelegate:self];        [UIView setAnimationWillStartSelector:@selector(animationWillStart:context:)];        [UIView setAnimationDidStopSelector:@selector(animationDidStop:finished:context:)];        [UIView commitAnimations];    }    else if ([animationID isEqualToString:@"yellow2"]) {        [UIView beginAnimations:@"black3" context:NULL];        [UIView setAnimationDelay:0.9];        _yellowView.backgroundColor=[UIColor blackColor];//        _redView.backgroundColor=[UIColor redColor];        [UIView setAnimationDelegate:self];        [UIView setAnimationWillStartSelector:@selector(animationWillStart:context:)];        [UIView setAnimationDidStopSelector:@selector(animationDidStop:finished:context:)];        [UIView commitAnimations];    }    else if ([animationID isEqualToString:@"black3"]) {        [UIView beginAnimations:@"red" context:NULL];        [UIView setAnimationDelay:0.1];//        _yellowView.backgroundColor=[UIColor blackColor];        _yellowView.bounds=CGRectMake(0, 0, 50, 50);        _redView.bounds=CGRectMake(0, 0, 100, 100);        _redView.backgroundColor=[UIColor redColor];        [UIView setAnimationDelegate:self];        [UIView setAnimationWillStartSelector:@selector(animationWillStart:context:)];        [UIView setAnimationDidStopSelector:@selector(animationDidStop:finished:context:)];        [UIView commitAnimations];    }    }//按鈕響應方法- (void)didClicked{    [UIView beginAnimations:@"red" context:NULL];//    [UIView setAnimationDuration:<#(NSTimeInterval)#>]    _redView.backgroundColor=[UIColor redColor];    _redView.bounds=CGRectMake(0, 0, 100, 100);//    _redView.center=CGPointMake(x, y+100);    [UIView setAnimationDelegate:self];    [UIView setAnimationWillStartSelector:@selector(animationWillStart:context:)];    [UIView setAnimationDidStopSelector:@selector(animationDidStop:finished:context:)];    [UIView commitAnimations];    }- (void)applicationWillResignActive:(UIApplication *)application {    // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.    // Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game.}- (void)applicationDidEnterBackground:(UIApplication *)application {    // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.    // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.}- (void)applicationWillEnterForeground:(UIApplication *)application {    // Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background.}- (void)applicationDidBecomeActive:(UIApplication *)application {    // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.}- (void)applicationWillTerminate:(UIApplication *)application {    // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.}@end

 

效果圖如下

要求基本實現


發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
亚洲香蕉成人av网站在线观看_欧美精品成人91久久久久久久_久久久久久久久久久亚洲_热久久视久久精品18亚洲精品_国产精自产拍久久久久久_亚洲色图国产精品_91精品国产网站_中文字幕欧美日韩精品_国产精品久久久久久亚洲调教_国产精品久久一区_性夜试看影院91社区_97在线观看视频国产_68精品久久久久久欧美_欧美精品在线观看_国产精品一区二区久久精品_欧美老女人bb
欧美成人网在线| 国产精品专区h在线观看| 亚洲国产成人精品一区二区| 国产成人高清激情视频在线观看| 黑人巨大精品欧美一区二区一视频| 性欧美亚洲xxxx乳在线观看| 亚洲电影免费观看高清完整版| 成人免费自拍视频| 97视频在线免费观看| 久久99久久99精品中文字幕| 欧美日韩一区二区免费视频| 91在线看www| 精品久久香蕉国产线看观看亚洲| 热门国产精品亚洲第一区在线| 国产在线a不卡| 欧美野外猛男的大粗鳮| 亚洲精品资源美女情侣酒店| 色噜噜国产精品视频一区二区| 精品国产视频在线| 国产va免费精品高清在线观看| 中文字幕亚洲一区| 午夜精品久久久久久久久久久久久| 日韩亚洲欧美中文在线| 亚洲va久久久噜噜噜| 久久久久久免费精品| 91国内精品久久| 国a精品视频大全| 亚洲欧美日本精品| 久久天天躁日日躁| 国产成人亚洲综合91| 91av在线视频观看| 国产日韩亚洲欧美| 欧美成人黑人xx视频免费观看| 成人黄色免费网站在线观看| 亚洲a区在线视频| 亚洲第一网中文字幕| 国产精品青青在线观看爽香蕉| 中文字幕精品一区二区精品| 欧美资源在线观看| 久久精品成人动漫| 久久天天躁狠狠躁夜夜爽蜜月| 亚洲国产女人aaa毛片在线| 播播国产欧美激情| 日本中文字幕不卡免费| 中文字幕精品一区久久久久| 国产欧美精品在线播放| 久久影视免费观看| 日韩美女视频免费看| 久久国产精品99国产精| 欧美激情视频在线| 成人动漫网站在线观看| 久久夜精品va视频免费观看| 国产精品久久久久久久av大片| 久久久久久亚洲精品中文字幕| 清纯唯美亚洲综合| 日韩欧美中文字幕在线播放| 欧美激情xxxxx| 精品久久香蕉国产线看观看gif| 欧美黑人极品猛少妇色xxxxx| 国产一区二区三区在线播放免费观看| 午夜精品久久久久久久白皮肤| 亚洲成人久久一区| 国产亚洲视频中文字幕视频| 97超级碰碰碰久久久| 欧美香蕉大胸在线视频观看| 亚洲第一偷拍网| 欧美最猛黑人xxxx黑人猛叫黄| 69久久夜色精品国产69| 亚洲福利精品在线| 97在线视频精品| 热久久这里只有精品| 精品久久久久久久久中文字幕| 欧美性猛交xxxxx免费看| 欧美性猛交xxxxx水多| 91精品中文在线| 久久久久久久久网站| 91久久久久久久久久久| 97人人爽人人喊人人模波多| 欧美性色视频在线| 国产精品亚洲一区二区三区| 欧亚精品中文字幕| 国产精品video| 日韩av黄色在线观看| 奇米成人av国产一区二区三区| 色噜噜国产精品视频一区二区| 久久视频精品在线| 国产精品爱久久久久久久| 国产婷婷97碰碰久久人人蜜臀| 欧美国产精品va在线观看| 91av视频在线观看| 中文字幕国产亚洲| 久久精品99久久久久久久久| 在线视频亚洲欧美| 伊人一区二区三区久久精品| 欧美性xxxxxx| 久久精品成人欧美大片古装| 亚洲free性xxxx护士hd| 欧美大片网站在线观看| 日本免费在线精品| 欧美成在线观看| 欧美一区视频在线| 国产精品久久久久久久久久99| 中文日韩在线视频| 海角国产乱辈乱精品视频| 欧美成人午夜免费视在线看片| 91精品啪aⅴ在线观看国产| 欧美大全免费观看电视剧大泉洋| 亚洲级视频在线观看免费1级| 91在线视频免费| 欧美国产日韩一区二区在线观看| 欧美激情视频在线| 亚洲视频专区在线| 精品二区三区线观看| 亚洲免费高清视频| 亚洲一区二区三区乱码aⅴ蜜桃女| 色777狠狠综合秋免鲁丝| 一区二区三区动漫| 欧美激情视频免费观看| 久久精品国产亚洲精品| 成人黄色免费在线观看| 亚洲人成网站在线播| 成人欧美一区二区三区在线| 亚洲精品大尺度| 裸体女人亚洲精品一区| 久久99青青精品免费观看| 欧美xxxx14xxxxx性爽| 亚洲欧美在线免费观看| 亚洲丁香久久久| 久久久免费观看| 日韩av在线最新| 91精品国产自产91精品| 一个色综合导航| 日韩欧美成人网| 3344国产精品免费看| 欧美重口另类videos人妖| 久久精品91久久香蕉加勒比| 国产一区二区三区直播精品电影| 美女999久久久精品视频| 精品中文字幕在线观看| 日韩中文视频免费在线观看| 一区二区国产精品视频| 51午夜精品视频| 精品国内产的精品视频在线观看| 欧美专区日韩视频| 日韩av网站电影| 国产精品久久久久久久久借妻| 视频在线一区二区| 亚洲天堂成人在线| 一区二区三区亚洲| 久久人人爽人人爽人人片av高请| 91国在线精品国内播放| 国产精品夫妻激情| 九九热99久久久国产盗摄| 成人啪啪免费看| 日韩人体视频一二区| 51精品国产黑色丝袜高跟鞋| 国产午夜精品理论片a级探花| 国语自产偷拍精品视频偷| 久久精品国产99国产精品澳门| 欧美精品在线视频观看| 91影院在线免费观看视频| 欧洲成人午夜免费大片| 九九九久久国产免费| 在线亚洲国产精品网|