iOS UI01_色彩变换
2015-07-30 22:18
357 查看
//
// AppDelegate.m
// 作业_彩色变换
//
// Created by dllo on 15/7/29.
// Copyright (c) 2015年 zhozhicheng. All rights reserved.
//
#import "AppDelegate.h"
@interface
AppDelegate ()
@end
@implementation AppDelegate
-(void)dealloc
{
[_window
release];
[super
dealloc];
}
- (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];
[_window
release];
UIView *view1=[[UIView
alloc] initWithFrame:CGRectMake(20, 20, 300, 300)];
view1.backgroundColor=[UIColor
blackColor];
[self.window
addSubview:view1];
[view1
release];
UIView *view2=[[UIView
alloc] initWithFrame:CGRectMake(40, 40, 260, 260)];
view2.backgroundColor=[UIColor
yellowColor];
[self.window
addSubview:view2];
[view2
release];
UIView *view3=[[UIView
alloc] initWithFrame:CGRectMake(60, 60, 220, 220)];
view3.backgroundColor=[UIColor
blueColor];
[self.window
addSubview:view3];
[view3
release];
UIView *view4=[[UIView
alloc] initWithFrame:CGRectMake(80, 80, 180, 180)];
view4.backgroundColor=[UIColor
redColor];
[self.window
addSubview:view4];
[view4
release];
UIView *view5=[[UIView
alloc] initWithFrame:CGRectMake(100, 100, 140, 140)];
view5.backgroundColor=[UIColor
orangeColor];
[self.window
addSubview:view5];
[view5
release];
UIView *view6=[[UIView
alloc] initWithFrame:CGRectMake(120, 120, 100, 100)];
view6.backgroundColor=[UIColor
cyanColor];
[self.window
addSubview:view6];
[view6
release];
UIView *view7=[[UIView
alloc] initWithFrame:CGRectMake(140, 140, 60, 60)];
view7.backgroundColor=[UIColor
greenColor];
[self.window
addSubview:view7];
[view7
release];
view1.tag=1;
view2.tag=2;
view3.tag=3;
view4.tag=4;
view5.tag=5;
view6.tag=6;
view7.tag=7;
NSTimer *timer=[NSTimer
scheduledTimerWithTimeInterval:0.5
target:self
selector:@selector(changeColor)
userInfo:nil
repeats:YES];
return
YES;
}
-(void)changeColor
{
UIColor *color =[self.window
viewWithTag:7].backgroundColor;
for (int i=6; i>0; i--) {
[self.window
viewWithTag:i+1].backgroundColor=[self.window
viewWithTag:i].backgroundColor;
}
[self.window
viewWithTag:1].backgroundColor=color;
}
- (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
// AppDelegate.m
// 作业_彩色变换
//
// Created by dllo on 15/7/29.
// Copyright (c) 2015年 zhozhicheng. All rights reserved.
//
#import "AppDelegate.h"
@interface
AppDelegate ()
@end
@implementation AppDelegate
-(void)dealloc
{
[_window
release];
[super
dealloc];
}
- (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];
[_window
release];
UIView *view1=[[UIView
alloc] initWithFrame:CGRectMake(20, 20, 300, 300)];
view1.backgroundColor=[UIColor
blackColor];
[self.window
addSubview:view1];
[view1
release];
UIView *view2=[[UIView
alloc] initWithFrame:CGRectMake(40, 40, 260, 260)];
view2.backgroundColor=[UIColor
yellowColor];
[self.window
addSubview:view2];
[view2
release];
UIView *view3=[[UIView
alloc] initWithFrame:CGRectMake(60, 60, 220, 220)];
view3.backgroundColor=[UIColor
blueColor];
[self.window
addSubview:view3];
[view3
release];
UIView *view4=[[UIView
alloc] initWithFrame:CGRectMake(80, 80, 180, 180)];
view4.backgroundColor=[UIColor
redColor];
[self.window
addSubview:view4];
[view4
release];
UIView *view5=[[UIView
alloc] initWithFrame:CGRectMake(100, 100, 140, 140)];
view5.backgroundColor=[UIColor
orangeColor];
[self.window
addSubview:view5];
[view5
release];
UIView *view6=[[UIView
alloc] initWithFrame:CGRectMake(120, 120, 100, 100)];
view6.backgroundColor=[UIColor
cyanColor];
[self.window
addSubview:view6];
[view6
release];
UIView *view7=[[UIView
alloc] initWithFrame:CGRectMake(140, 140, 60, 60)];
view7.backgroundColor=[UIColor
greenColor];
[self.window
addSubview:view7];
[view7
release];
view1.tag=1;
view2.tag=2;
view3.tag=3;
view4.tag=4;
view5.tag=5;
view6.tag=6;
view7.tag=7;
NSTimer *timer=[NSTimer
scheduledTimerWithTimeInterval:0.5
target:self
selector:@selector(changeColor)
userInfo:nil
repeats:YES];
return
YES;
}
-(void)changeColor
{
UIColor *color =[self.window
viewWithTag:7].backgroundColor;
for (int i=6; i>0; i--) {
[self.window
viewWithTag:i+1].backgroundColor=[self.window
viewWithTag:i].backgroundColor;
}
[self.window
viewWithTag:1].backgroundColor=color;
}
- (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
相关文章推荐
- IOS--UI--LessonGCD
- mapreduce--使用自定义类做value
- 写在Demo战斗系统之前,先用原型工具做套UI第三篇-常规UI界面制作
- DataTable转Json(兼容easyUI特殊json分页)
- 如何实现EditPlus、UE等工具的列选择,并且将选择的列复制到word中的表格
- 如何实现EditPlus、UE等工具的列选择,并且将选择的列复制到word中的表格
- IOS第五天(2:用户登录,回车的监听(代理模式UITextFieldDelegate)) 和关闭键盘
- sgu 455. Sequence analysis (floyd 判圈算法,O(1)空间复杂度求循环节)
- 读书笔记-APUE第三版-(9)进程关系
- (easy)LeetCode 232.Implement Queue using Stacks
- iOS 动画UIViewAnimationOptions类型
- iOS -UI汤姆猫实现(UIImageView)自己写的汤姆猫,所学知识有限,代码还有待改进 ==
- iOS阶段学习第29天笔记(UITextField的介绍)
- UIButton
- IOS--UI--LessonThread 线程
- UIView
- UIScrollView
- wfp数据类型转换--Uint16转二进制字符串
- UI01_UILabel(加粗,文字是否高亮,文字是否可变,文字是否自适应label宽度)
- Visual GDB 工程 使用ndk-build命令失败的解决方法