From 12f59202b9673a1b13e4f7f21eafa27929a89614 Mon Sep 17 00:00:00 2001 From: Weien Wang Date: Thu, 31 Oct 2013 11:34:57 -0500 Subject: [PATCH 01/14] [ADD] basic background image to both view controllers --- ChangingBackground/FirstViewController.m | 9 +++++++++ ChangingBackground/SecondViewController.m | 9 +++++++++ 2 files changed, 18 insertions(+) diff --git a/ChangingBackground/FirstViewController.m b/ChangingBackground/FirstViewController.m index 8aedb68..75c1716 100644 --- a/ChangingBackground/FirstViewController.m +++ b/ChangingBackground/FirstViewController.m @@ -20,4 +20,13 @@ - (IBAction)goForwardButtonPressed { [self.navigationController pushViewController:secondViewController animated:YES]; } +- (void) viewDidLoad { + UIImage* backgroundImage = [UIImage imageNamed:@"blue.png"]; + UIImageView* background = [[UIImageView alloc] initWithImage:backgroundImage]; + + [self.view addSubview:background]; + [self.view sendSubviewToBack:background]; + +} + @end diff --git a/ChangingBackground/SecondViewController.m b/ChangingBackground/SecondViewController.m index 028f811..fa31304 100644 --- a/ChangingBackground/SecondViewController.m +++ b/ChangingBackground/SecondViewController.m @@ -15,4 +15,13 @@ - (IBAction)goBackButtonPressed { [self.navigationController popViewControllerAnimated:YES]; } +- (void) viewDidLoad { + UIImage* backgroundImage = [UIImage imageNamed:@"blue.png"]; + UIImageView* background = [[UIImageView alloc] initWithImage:backgroundImage]; + + [self.view addSubview:background]; + [self.view sendSubviewToBack:background]; +} + + @end From 71df35afe5b33b90c4613546012ef91590592139 Mon Sep 17 00:00:00 2001 From: Weien Wang Date: Thu, 31 Oct 2013 11:35:20 -0500 Subject: [PATCH 02/14] [ADD] color/aesthetic changes to labels, for visibility --- ChangingBackground/FirstViewController.xib | 258 +++--------------- ChangingBackground/SecondViewController.xib | 282 +++----------------- 2 files changed, 80 insertions(+), 460 deletions(-) diff --git a/ChangingBackground/FirstViewController.xib b/ChangingBackground/FirstViewController.xib index 0dd58c2..f171ea5 100644 --- a/ChangingBackground/FirstViewController.xib +++ b/ChangingBackground/FirstViewController.xib @@ -1,217 +1,41 @@ - - - - 1552 - 12C3006 - 3084 - 1187.34 - 625.00 - - com.apple.InterfaceBuilder.IBCocoaTouchPlugin - 2083 - - - IBProxyObject - IBUIButton - IBUILabel - IBUIView - - - com.apple.InterfaceBuilder.IBCocoaTouchPlugin - - - PluginDependencyRecalculationVersion - - - - - IBFilesOwner - IBCocoaTouchFramework - - - IBFirstResponder - IBCocoaTouchFramework - - - - 274 - - - - 292 - {{77, 115}, {166, 21}} - - - _NS:9 - NO - YES - 7 - NO - IBCocoaTouchFramework - Home View Controller - - 1 - MCAwIDAAA - darkTextColor - - - 0 - - 1 - 17 - - - Helvetica - 17 - 16 - - NO - - - - 292 - {{102, 180}, {109, 44}} - - _NS:9 - NO - IBCocoaTouchFramework - 0 - 0 - 1 - Go Forward - - 3 - MQA - - - 1 - MC4xOTYwNzg0MzQ2IDAuMzA5ODAzOTMyOSAwLjUyMTU2ODY1NgA - - - 3 - MC41AA - - - 2 - 15 - - - Helvetica-Bold - 15 - 16 - - - - {{0, 20}, {320, 548}} - - - 3 - MQA - - 2 - - - - - IBUIScreenMetrics - - YES - - - - - - {320, 568} - {568, 320} - - - IBCocoaTouchFramework - Retina 4 Full Screen - 2 - - IBCocoaTouchFramework - - - - - - - view - - - - 3 - - - - goForwardButtonPressed - - - 7 - - 8 - - - - - - 0 - - - - - - 1 - - - - - - - - - -1 - - - File's Owner - - - -2 - - - - - 4 - - - - - 7 - - - - - - - FirstViewController - com.apple.InterfaceBuilder.IBCocoaTouchPlugin - UIResponder - com.apple.InterfaceBuilder.IBCocoaTouchPlugin - com.apple.InterfaceBuilder.IBCocoaTouchPlugin - com.apple.InterfaceBuilder.IBCocoaTouchPlugin - com.apple.InterfaceBuilder.IBCocoaTouchPlugin - - - - - - 8 - - - 0 - IBCocoaTouchFramework - YES - 3 - 2083 - - + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/ChangingBackground/SecondViewController.xib b/ChangingBackground/SecondViewController.xib index d603949..7317a7d 100644 --- a/ChangingBackground/SecondViewController.xib +++ b/ChangingBackground/SecondViewController.xib @@ -1,243 +1,39 @@ - - - - 1552 - 12C3006 - 3084 - 1187.34 - 625.00 - - com.apple.InterfaceBuilder.IBCocoaTouchPlugin - 2083 - - - IBProxyObject - IBUIButton - IBUILabel - IBUIView - - - com.apple.InterfaceBuilder.IBCocoaTouchPlugin - - - PluginDependencyRecalculationVersion - - - - - IBFilesOwner - IBCocoaTouchFramework - - - IBFirstResponder - IBCocoaTouchFramework - - - - 274 - - - - 292 - {{71, 118}, {209, 21}} - - - - _NS:9 - NO - YES - 7 - NO - IBCocoaTouchFramework - Second View Controller - - 1 - MCAwIDAAA - darkTextColor - - - 0 - - 1 - 17 - - - Helvetica - 17 - 16 - - NO - - - - 292 - {{118, 178}, {85, 44}} - - - _NS:9 - NO - IBCocoaTouchFramework - 0 - 0 - 1 - Go Back - - 3 - MQA - - - 1 - MC4xOTYwNzg0MzQ2IDAuMzA5ODAzOTMyOSAwLjUyMTU2ODY1NgA - - - 3 - MC41AA - - - 2 - 15 - - - Helvetica-Bold - 15 - 16 - - - - {{0, 20}, {320, 548}} - - - - - 3 - MQA - - 2 - - - - - IBUIScreenMetrics - - YES - - - - - - {320, 568} - {568, 320} - - - IBCocoaTouchFramework - Retina 4 Full Screen - 2 - - IBCocoaTouchFramework - - - - - - - view - - - - 3 - - - - goBackButtonPressed - - - 7 - - 10 - - - - - - 0 - - - - - - 1 - - - - - - - - - -1 - - - File's Owner - - - -2 - - - - - 4 - - - - - 7 - - - - - - - SecondViewController - com.apple.InterfaceBuilder.IBCocoaTouchPlugin - UIResponder - com.apple.InterfaceBuilder.IBCocoaTouchPlugin - com.apple.InterfaceBuilder.IBCocoaTouchPlugin - com.apple.InterfaceBuilder.IBCocoaTouchPlugin - com.apple.InterfaceBuilder.IBCocoaTouchPlugin - - - - - - 10 - - - - - SecondViewController - UIViewController - - goBackButtonPressed - id - - - goBackButtonPressed - - goBackButtonPressed - id - - - - IBProjectSource - ./Classes/SecondViewController.h - - - - - 0 - IBCocoaTouchFramework - YES - 3 - 2083 - - + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file From 4d1cd111fe9df5f455b72100618f9b0f3fc6933d Mon Sep 17 00:00:00 2001 From: Weien Wang Date: Thu, 31 Oct 2013 13:06:56 -0500 Subject: [PATCH 03/14] [ADD] quartzcore framework --- ChangingBackground.xcodeproj/project.pbxproj | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/ChangingBackground.xcodeproj/project.pbxproj b/ChangingBackground.xcodeproj/project.pbxproj index 2e16be1..99d7465 100644 --- a/ChangingBackground.xcodeproj/project.pbxproj +++ b/ChangingBackground.xcodeproj/project.pbxproj @@ -24,6 +24,7 @@ 001809EC171C6764002D3E93 /* blue@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 001809E8171C6764002D3E93 /* blue@2x.png */; }; 001809ED171C6764002D3E93 /* green.png in Resources */ = {isa = PBXBuildFile; fileRef = 001809E9171C6764002D3E93 /* green.png */; }; 001809EE171C6764002D3E93 /* green@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 001809EA171C6764002D3E93 /* green@2x.png */; }; + 647617291822C12B002D52E5 /* QuartzCore.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 647617281822C12B002D52E5 /* QuartzCore.framework */; }; /* End PBXBuildFile section */ /* Begin PBXFileReference section */ @@ -50,6 +51,7 @@ 001809E8171C6764002D3E93 /* blue@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "blue@2x.png"; sourceTree = ""; }; 001809E9171C6764002D3E93 /* green.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = green.png; sourceTree = ""; }; 001809EA171C6764002D3E93 /* green@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "green@2x.png"; sourceTree = ""; }; + 647617281822C12B002D52E5 /* QuartzCore.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = QuartzCore.framework; path = System/Library/Frameworks/QuartzCore.framework; sourceTree = SDKROOT; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -57,6 +59,7 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( + 647617291822C12B002D52E5 /* QuartzCore.framework in Frameworks */, 001809B9171C637E002D3E93 /* UIKit.framework in Frameworks */, 001809BB171C637E002D3E93 /* Foundation.framework in Frameworks */, 001809BD171C637E002D3E93 /* CoreGraphics.framework in Frameworks */, @@ -86,6 +89,7 @@ 001809B7171C637E002D3E93 /* Frameworks */ = { isa = PBXGroup; children = ( + 647617281822C12B002D52E5 /* QuartzCore.framework */, 001809B8171C637E002D3E93 /* UIKit.framework */, 001809BA171C637E002D3E93 /* Foundation.framework */, 001809BC171C637E002D3E93 /* CoreGraphics.framework */, @@ -356,6 +360,7 @@ 001809D4171C637E002D3E93 /* Release */, ); defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; }; /* End XCConfigurationList section */ }; From 6e24fbfd5f9d3d6bfcc9c47bc12c4aeafc5dff61 Mon Sep 17 00:00:00 2001 From: Weien Wang Date: Thu, 31 Oct 2013 13:08:15 -0500 Subject: [PATCH 04/14] =?UTF-8?q?[ADD]=20(first=20attempt)=20=E2=80=94=20b?= =?UTF-8?q?ackground=20image=20on=20UIWindow,=20clear=20backgrounds=20for?= =?UTF-8?q?=20view=20controllers.=20Results=20in=20odd=20iOS=207=20choppin?= =?UTF-8?q?ess.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ChangingBackground/AppDelegate.m | 2 ++ ChangingBackground/FirstViewController.m | 14 +++++++++----- ChangingBackground/SecondViewController.m | 11 +++++++---- 3 files changed, 18 insertions(+), 9 deletions(-) diff --git a/ChangingBackground/AppDelegate.m b/ChangingBackground/AppDelegate.m index 9538cc1..176367c 100644 --- a/ChangingBackground/AppDelegate.m +++ b/ChangingBackground/AppDelegate.m @@ -19,6 +19,8 @@ @implementation AppDelegate - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { window = [UIWindow.alloc initWithFrame:UIScreen.mainScreen.bounds]; + UIColor *background = [[UIColor alloc] initWithPatternImage:[UIImage imageNamed:@"blue.png"]]; + window.backgroundColor = background; [window makeKeyAndVisible]; FirstViewController *firstViewController = FirstViewController.new; diff --git a/ChangingBackground/FirstViewController.m b/ChangingBackground/FirstViewController.m index 75c1716..133bf56 100644 --- a/ChangingBackground/FirstViewController.m +++ b/ChangingBackground/FirstViewController.m @@ -6,6 +6,8 @@ // Copyright (c) 2013 Ora Interactive. All rights reserved. // +#import + #import "FirstViewController.h" #import "SecondViewController.h" @@ -21,12 +23,14 @@ - (IBAction)goForwardButtonPressed { } - (void) viewDidLoad { - UIImage* backgroundImage = [UIImage imageNamed:@"blue.png"]; - UIImageView* background = [[UIImageView alloc] initWithImage:backgroundImage]; - - [self.view addSubview:background]; - [self.view sendSubviewToBack:background]; + [super viewDidLoad]; + self.view.backgroundColor = [UIColor clearColor]; +// UIImage* backgroundImage = [UIImage imageNamed:@"blue.png"]; +// UIImageView* background = [[UIImageView alloc] initWithImage:backgroundImage]; +// +// [self.view addSubview:background]; +// [self.view sendSubviewToBack:background]; } @end diff --git a/ChangingBackground/SecondViewController.m b/ChangingBackground/SecondViewController.m index fa31304..586c10c 100644 --- a/ChangingBackground/SecondViewController.m +++ b/ChangingBackground/SecondViewController.m @@ -16,11 +16,14 @@ - (IBAction)goBackButtonPressed { } - (void) viewDidLoad { - UIImage* backgroundImage = [UIImage imageNamed:@"blue.png"]; - UIImageView* background = [[UIImageView alloc] initWithImage:backgroundImage]; + [super viewDidLoad]; + self.view.backgroundColor = [UIColor clearColor]; - [self.view addSubview:background]; - [self.view sendSubviewToBack:background]; +// UIImage* backgroundImage = [UIImage imageNamed:@"blue.png"]; +// UIImageView* background = [[UIImageView alloc] initWithImage:backgroundImage]; +// +// [self.view addSubview:background]; +// [self.view sendSubviewToBack:background]; } From 3d761ec201c882ae244ef814fa4140c4c43063a4 Mon Sep 17 00:00:00 2001 From: Weien Wang Date: Thu, 31 Oct 2013 14:32:54 -0500 Subject: [PATCH 05/14] [FIX] change SDK to 6.1, deployment target to 6.0, to avoid bug with iOS 7 UINavigationController transition --- ChangingBackground.xcodeproj/project.pbxproj | 10 ++++++---- ChangingBackground/FirstViewController.xib | 8 ++++---- ChangingBackground/SecondViewController.xib | 8 ++++---- 3 files changed, 14 insertions(+), 12 deletions(-) diff --git a/ChangingBackground.xcodeproj/project.pbxproj b/ChangingBackground.xcodeproj/project.pbxproj index 99d7465..c56460a 100644 --- a/ChangingBackground.xcodeproj/project.pbxproj +++ b/ChangingBackground.xcodeproj/project.pbxproj @@ -288,9 +288,9 @@ GCC_WARN_ABOUT_RETURN_TYPE = YES; GCC_WARN_UNINITIALIZED_AUTOS = YES; GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 6.1; + IPHONEOS_DEPLOYMENT_TARGET = 6.0; ONLY_ACTIVE_ARCH = YES; - SDKROOT = iphoneos; + SDKROOT = iphoneos6.1; }; name = Debug; }; @@ -312,9 +312,9 @@ GCC_WARN_ABOUT_RETURN_TYPE = YES; GCC_WARN_UNINITIALIZED_AUTOS = YES; GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 6.1; + IPHONEOS_DEPLOYMENT_TARGET = 6.0; OTHER_CFLAGS = "-DNS_BLOCK_ASSERTIONS=1"; - SDKROOT = iphoneos; + SDKROOT = iphoneos6.1; VALIDATE_PRODUCT = YES; }; name = Release; @@ -325,6 +325,7 @@ GCC_PRECOMPILE_PREFIX_HEADER = YES; GCC_PREFIX_HEADER = "ChangingBackground/ChangingBackground-Prefix.pch"; INFOPLIST_FILE = "ChangingBackground/ChangingBackground-Info.plist"; + IPHONEOS_DEPLOYMENT_TARGET = 6.0; PRODUCT_NAME = "$(TARGET_NAME)"; WRAPPER_EXTENSION = app; }; @@ -336,6 +337,7 @@ GCC_PRECOMPILE_PREFIX_HEADER = YES; GCC_PREFIX_HEADER = "ChangingBackground/ChangingBackground-Prefix.pch"; INFOPLIST_FILE = "ChangingBackground/ChangingBackground-Info.plist"; + IPHONEOS_DEPLOYMENT_TARGET = 6.0; PRODUCT_NAME = "$(TARGET_NAME)"; WRAPPER_EXTENSION = app; }; diff --git a/ChangingBackground/FirstViewController.xib b/ChangingBackground/FirstViewController.xib index f171ea5..637e01d 100644 --- a/ChangingBackground/FirstViewController.xib +++ b/ChangingBackground/FirstViewController.xib @@ -1,7 +1,7 @@ - + - + @@ -12,7 +12,7 @@ - + - + \ No newline at end of file diff --git a/ChangingBackground/SecondViewController.xib b/ChangingBackground/SecondViewController.xib index 7317a7d..9154eac 100644 --- a/ChangingBackground/SecondViewController.xib +++ b/ChangingBackground/SecondViewController.xib @@ -1,7 +1,7 @@ - + - + @@ -12,7 +12,7 @@ - + - + \ No newline at end of file From 54363556831de01dcd687b18df21eeb0fa255b8d Mon Sep 17 00:00:00 2001 From: Weien Wang Date: Thu, 31 Oct 2013 14:45:52 -0500 Subject: [PATCH 06/14] [ADD] basic background color animation on viewDidAppear (not working) --- ChangingBackground/FirstViewController.m | 13 +++++++++++++ ChangingBackground/SecondViewController.m | 14 ++++++++++++-- 2 files changed, 25 insertions(+), 2 deletions(-) diff --git a/ChangingBackground/FirstViewController.m b/ChangingBackground/FirstViewController.m index 133bf56..2d3347b 100644 --- a/ChangingBackground/FirstViewController.m +++ b/ChangingBackground/FirstViewController.m @@ -33,4 +33,17 @@ - (void) viewDidLoad { // [self.view sendSubviewToBack:background]; } +- (void) viewDidAppear:(BOOL)animated { + [super viewDidAppear:animated]; + + UIWindow* window = [UIApplication sharedApplication].keyWindow; + UIColor *newBackground = [[UIColor alloc] initWithPatternImage:[UIImage imageNamed:@"blue.png"]]; + + if (window.backgroundColor != newBackground) { + [UIView animateWithDuration:1.0 delay:1.0 options:UIViewAnimationOptionTransitionNone animations:^{ + window.backgroundColor = newBackground; + } completion:NULL]; + } +} + @end diff --git a/ChangingBackground/SecondViewController.m b/ChangingBackground/SecondViewController.m index 586c10c..331c8e5 100644 --- a/ChangingBackground/SecondViewController.m +++ b/ChangingBackground/SecondViewController.m @@ -19,12 +19,22 @@ - (void) viewDidLoad { [super viewDidLoad]; self.view.backgroundColor = [UIColor clearColor]; -// UIImage* backgroundImage = [UIImage imageNamed:@"blue.png"]; +// UIImage* backgroundImage = [UIImage imageNamed:@"green.png"]; // UIImageView* background = [[UIImageView alloc] initWithImage:backgroundImage]; -// +// // [self.view addSubview:background]; // [self.view sendSubviewToBack:background]; } +- (void) viewDidAppear:(BOOL)animated { + [super viewDidAppear:animated]; + + UIWindow* window = [UIApplication sharedApplication].keyWindow; + UIColor *newBackground = [[UIColor alloc] initWithPatternImage:[UIImage imageNamed:@"green.png"]]; + + [UIView animateWithDuration:1.0 delay:1.0 options:UIViewAnimationOptionTransitionNone animations:^{ + window.backgroundColor = newBackground; + } completion:NULL]; +} @end From 92f831d791b66e9432f3032c9b04e55f3630b8af Mon Sep 17 00:00:00 2001 From: Weien Wang Date: Thu, 31 Oct 2013 16:25:11 -0500 Subject: [PATCH 07/14] [FIX] color change animation; use window subview approach instead of backgroundColor approach --- ChangingBackground/AppDelegate.m | 15 +++++++++++++-- ChangingBackground/FirstViewController.m | 19 +++++++++++++++---- ChangingBackground/SecondViewController.m | 17 +++++++++++++---- 3 files changed, 41 insertions(+), 10 deletions(-) diff --git a/ChangingBackground/AppDelegate.m b/ChangingBackground/AppDelegate.m index 176367c..3e498f9 100644 --- a/ChangingBackground/AppDelegate.m +++ b/ChangingBackground/AppDelegate.m @@ -19,8 +19,19 @@ @implementation AppDelegate - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { window = [UIWindow.alloc initWithFrame:UIScreen.mainScreen.bounds]; - UIColor *background = [[UIColor alloc] initWithPatternImage:[UIImage imageNamed:@"blue.png"]]; - window.backgroundColor = background; + + UIImage* blueBackgroundImage = [UIImage imageNamed:@"blue.png"]; + UIImageView* blueBackground = [[UIImageView alloc] initWithImage:blueBackgroundImage]; + + [window addSubview:blueBackground]; + + UIImage* greenBackgroundImage = [UIImage imageNamed:@"green.png"]; + UIImageView* greenBackground = [[UIImageView alloc] initWithImage:greenBackgroundImage]; + greenBackground.alpha = 0.0; + [window addSubview:greenBackground]; + + //UIColor *background = [[UIColor alloc] initWithPatternImage:[UIImage imageNamed:@"blue.png"]]; + //window.backgroundColor = background; [window makeKeyAndVisible]; FirstViewController *firstViewController = FirstViewController.new; diff --git a/ChangingBackground/FirstViewController.m b/ChangingBackground/FirstViewController.m index 2d3347b..d30bdb0 100644 --- a/ChangingBackground/FirstViewController.m +++ b/ChangingBackground/FirstViewController.m @@ -37,13 +37,24 @@ - (void) viewDidAppear:(BOOL)animated { [super viewDidAppear:animated]; UIWindow* window = [UIApplication sharedApplication].keyWindow; - UIColor *newBackground = [[UIColor alloc] initWithPatternImage:[UIImage imageNamed:@"blue.png"]]; - if (window.backgroundColor != newBackground) { - [UIView animateWithDuration:1.0 delay:1.0 options:UIViewAnimationOptionTransitionNone animations:^{ - window.backgroundColor = newBackground; + UIImageView* blueBackground = [[window subviews] objectAtIndex:0]; + UIImageView* greenBackground = [[window subviews] objectAtIndex:1]; + + if (blueBackground.alpha != 1.0) { + [UIView animateWithDuration:1.5 delay:0.3 options:UIViewAnimationOptionTransitionNone animations:^{ + blueBackground.alpha = 1.0; + greenBackground.alpha = 0.0; } completion:NULL]; } + +// UIColor *newBackground = [[UIColor alloc] initWithPatternImage:[UIImage imageNamed:@"blue.png"]]; +// +// if (window.backgroundColor != newBackground) { +// [UIView animateWithDuration:1.0 delay:1.0 options:UIViewAnimationOptionTransitionNone animations:^{ +// window.backgroundColor = newBackground; +// } completion:NULL]; +// } } @end diff --git a/ChangingBackground/SecondViewController.m b/ChangingBackground/SecondViewController.m index 331c8e5..bca001e 100644 --- a/ChangingBackground/SecondViewController.m +++ b/ChangingBackground/SecondViewController.m @@ -23,18 +23,27 @@ - (void) viewDidLoad { // UIImageView* background = [[UIImageView alloc] initWithImage:backgroundImage]; // // [self.view addSubview:background]; -// [self.view sendSubviewToBack:background]; +// [self.view sendSubviewToBack:background] } - (void) viewDidAppear:(BOOL)animated { [super viewDidAppear:animated]; UIWindow* window = [UIApplication sharedApplication].keyWindow; - UIColor *newBackground = [[UIColor alloc] initWithPatternImage:[UIImage imageNamed:@"green.png"]]; + UIImageView* blueBackground = [[window subviews] objectAtIndex:0]; + UIImageView* greenBackground = [[window subviews] objectAtIndex:1]; - [UIView animateWithDuration:1.0 delay:1.0 options:UIViewAnimationOptionTransitionNone animations:^{ - window.backgroundColor = newBackground; + [UIView animateWithDuration:1.5 delay:0.3 options:UIViewAnimationOptionTransitionNone animations:^{ + blueBackground.alpha = 0.0; + greenBackground.alpha = 1.0; } completion:NULL]; + + +// UIColor *newBackground = [[UIColor alloc] initWithPatternImage:[UIImage imageNamed:@"green.png"]]; +// +// [UIView animateWithDuration:1.0 delay:1.0 options:UIViewAnimationOptionTransitionNone animations:^{ +// window.backgroundColor = newBackground; +// } completion:NULL]; } @end From febef8cb85663460f09bbfb6d1f76b6eeed15c0b Mon Sep 17 00:00:00 2001 From: Weien Wang Date: Thu, 31 Oct 2013 16:34:59 -0500 Subject: [PATCH 08/14] [FIX] status bar text color --- ChangingBackground/ChangingBackground-Info.plist | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/ChangingBackground/ChangingBackground-Info.plist b/ChangingBackground/ChangingBackground-Info.plist index bab2011..fdb2721 100644 --- a/ChangingBackground/ChangingBackground-Info.plist +++ b/ChangingBackground/ChangingBackground-Info.plist @@ -2,6 +2,12 @@ + UIViewControllerBasedStatusBarAppearance + + UIStatusBarHidden + + UIStatusBarStyle + UIStatusBarStyleLightContent CFBundleDevelopmentRegion en CFBundleDisplayName From fe58915c94c41d4ed46173bae07740650f542be2 Mon Sep 17 00:00:00 2001 From: Weien Wang Date: Thu, 31 Oct 2013 16:35:28 -0500 Subject: [PATCH 09/14] =?UTF-8?q?change=20SDK=20root=20back=20to=207=20for?= =?UTF-8?q?=20now=20(as=20long=20as=20it=20doesn=E2=80=99t=20seem=20to=20m?= =?UTF-8?q?ake=20a=20difference)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ChangingBackground.xcodeproj/project.pbxproj | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ChangingBackground.xcodeproj/project.pbxproj b/ChangingBackground.xcodeproj/project.pbxproj index c56460a..633fb32 100644 --- a/ChangingBackground.xcodeproj/project.pbxproj +++ b/ChangingBackground.xcodeproj/project.pbxproj @@ -290,7 +290,7 @@ GCC_WARN_UNUSED_VARIABLE = YES; IPHONEOS_DEPLOYMENT_TARGET = 6.0; ONLY_ACTIVE_ARCH = YES; - SDKROOT = iphoneos6.1; + SDKROOT = iphoneos7.0; }; name = Debug; }; @@ -314,7 +314,7 @@ GCC_WARN_UNUSED_VARIABLE = YES; IPHONEOS_DEPLOYMENT_TARGET = 6.0; OTHER_CFLAGS = "-DNS_BLOCK_ASSERTIONS=1"; - SDKROOT = iphoneos6.1; + SDKROOT = iphoneos7.0; VALIDATE_PRODUCT = YES; }; name = Release; From 4e25e8c904ab0a4fa8ad862187b95964706c7f78 Mon Sep 17 00:00:00 2001 From: Weien Wang Date: Thu, 31 Oct 2013 16:35:47 -0500 Subject: [PATCH 10/14] [FIX] relevant alphas for the uiimageviews to make effect more subtle --- ChangingBackground/AppDelegate.m | 4 ++-- ChangingBackground/FirstViewController.m | 4 ++-- ChangingBackground/SecondViewController.m | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/ChangingBackground/AppDelegate.m b/ChangingBackground/AppDelegate.m index 3e498f9..21f9b38 100644 --- a/ChangingBackground/AppDelegate.m +++ b/ChangingBackground/AppDelegate.m @@ -22,12 +22,12 @@ - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:( UIImage* blueBackgroundImage = [UIImage imageNamed:@"blue.png"]; UIImageView* blueBackground = [[UIImageView alloc] initWithImage:blueBackgroundImage]; - + blueBackground.alpha = 0.8; [window addSubview:blueBackground]; UIImage* greenBackgroundImage = [UIImage imageNamed:@"green.png"]; UIImageView* greenBackground = [[UIImageView alloc] initWithImage:greenBackgroundImage]; - greenBackground.alpha = 0.0; + greenBackground.alpha = 0.2; [window addSubview:greenBackground]; //UIColor *background = [[UIColor alloc] initWithPatternImage:[UIImage imageNamed:@"blue.png"]]; diff --git a/ChangingBackground/FirstViewController.m b/ChangingBackground/FirstViewController.m index d30bdb0..fc6e0e4 100644 --- a/ChangingBackground/FirstViewController.m +++ b/ChangingBackground/FirstViewController.m @@ -43,8 +43,8 @@ - (void) viewDidAppear:(BOOL)animated { if (blueBackground.alpha != 1.0) { [UIView animateWithDuration:1.5 delay:0.3 options:UIViewAnimationOptionTransitionNone animations:^{ - blueBackground.alpha = 1.0; - greenBackground.alpha = 0.0; + blueBackground.alpha = 0.8; + greenBackground.alpha = 0.2; } completion:NULL]; } diff --git a/ChangingBackground/SecondViewController.m b/ChangingBackground/SecondViewController.m index bca001e..0c8d582 100644 --- a/ChangingBackground/SecondViewController.m +++ b/ChangingBackground/SecondViewController.m @@ -34,8 +34,8 @@ - (void) viewDidAppear:(BOOL)animated { UIImageView* greenBackground = [[window subviews] objectAtIndex:1]; [UIView animateWithDuration:1.5 delay:0.3 options:UIViewAnimationOptionTransitionNone animations:^{ - blueBackground.alpha = 0.0; - greenBackground.alpha = 1.0; + blueBackground.alpha = 0.2; + greenBackground.alpha = 0.8; } completion:NULL]; From 3448e7a3aec1e46746d45cbe2ade0a272d41f656 Mon Sep 17 00:00:00 2001 From: Weien Wang Date: Thu, 31 Oct 2013 16:37:10 -0500 Subject: [PATCH 11/14] [DONTNEED] commented-out code --- ChangingBackground/AppDelegate.m | 5 ++--- ChangingBackground/FirstViewController.m | 14 -------------- ChangingBackground/SecondViewController.m | 13 ------------- 3 files changed, 2 insertions(+), 30 deletions(-) diff --git a/ChangingBackground/AppDelegate.m b/ChangingBackground/AppDelegate.m index 21f9b38..58adc7b 100644 --- a/ChangingBackground/AppDelegate.m +++ b/ChangingBackground/AppDelegate.m @@ -23,15 +23,14 @@ - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:( UIImage* blueBackgroundImage = [UIImage imageNamed:@"blue.png"]; UIImageView* blueBackground = [[UIImageView alloc] initWithImage:blueBackgroundImage]; blueBackground.alpha = 0.8; - [window addSubview:blueBackground]; UIImage* greenBackgroundImage = [UIImage imageNamed:@"green.png"]; UIImageView* greenBackground = [[UIImageView alloc] initWithImage:greenBackgroundImage]; greenBackground.alpha = 0.2; + + [window addSubview:blueBackground]; [window addSubview:greenBackground]; - //UIColor *background = [[UIColor alloc] initWithPatternImage:[UIImage imageNamed:@"blue.png"]]; - //window.backgroundColor = background; [window makeKeyAndVisible]; FirstViewController *firstViewController = FirstViewController.new; diff --git a/ChangingBackground/FirstViewController.m b/ChangingBackground/FirstViewController.m index fc6e0e4..91ff42d 100644 --- a/ChangingBackground/FirstViewController.m +++ b/ChangingBackground/FirstViewController.m @@ -25,12 +25,6 @@ - (IBAction)goForwardButtonPressed { - (void) viewDidLoad { [super viewDidLoad]; self.view.backgroundColor = [UIColor clearColor]; - -// UIImage* backgroundImage = [UIImage imageNamed:@"blue.png"]; -// UIImageView* background = [[UIImageView alloc] initWithImage:backgroundImage]; -// -// [self.view addSubview:background]; -// [self.view sendSubviewToBack:background]; } - (void) viewDidAppear:(BOOL)animated { @@ -47,14 +41,6 @@ - (void) viewDidAppear:(BOOL)animated { greenBackground.alpha = 0.2; } completion:NULL]; } - -// UIColor *newBackground = [[UIColor alloc] initWithPatternImage:[UIImage imageNamed:@"blue.png"]]; -// -// if (window.backgroundColor != newBackground) { -// [UIView animateWithDuration:1.0 delay:1.0 options:UIViewAnimationOptionTransitionNone animations:^{ -// window.backgroundColor = newBackground; -// } completion:NULL]; -// } } @end diff --git a/ChangingBackground/SecondViewController.m b/ChangingBackground/SecondViewController.m index 0c8d582..acddb32 100644 --- a/ChangingBackground/SecondViewController.m +++ b/ChangingBackground/SecondViewController.m @@ -18,12 +18,6 @@ - (IBAction)goBackButtonPressed { - (void) viewDidLoad { [super viewDidLoad]; self.view.backgroundColor = [UIColor clearColor]; - -// UIImage* backgroundImage = [UIImage imageNamed:@"green.png"]; -// UIImageView* background = [[UIImageView alloc] initWithImage:backgroundImage]; -// -// [self.view addSubview:background]; -// [self.view sendSubviewToBack:background] } - (void) viewDidAppear:(BOOL)animated { @@ -37,13 +31,6 @@ - (void) viewDidAppear:(BOOL)animated { blueBackground.alpha = 0.2; greenBackground.alpha = 0.8; } completion:NULL]; - - -// UIColor *newBackground = [[UIColor alloc] initWithPatternImage:[UIImage imageNamed:@"green.png"]]; -// -// [UIView animateWithDuration:1.0 delay:1.0 options:UIViewAnimationOptionTransitionNone animations:^{ -// window.backgroundColor = newBackground; -// } completion:NULL]; } @end From fb48f877bd0c5b981410f4dd6e76df5e75424297 Mon Sep 17 00:00:00 2001 From: Weien Wang Date: Thu, 31 Oct 2013 17:04:49 -0500 Subject: [PATCH 12/14] =?UTF-8?q?[ADD]=20=E2=80=9CRetro=E2=80=9D=20navigat?= =?UTF-8?q?ionController=20animation=20to=20get=20around=20annoying=20iOS?= =?UTF-8?q?=207=20bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ChangingBackground.xcodeproj/project.pbxproj | 15 ++++++++ ChangingBackground/FirstViewController.m | 5 +-- ChangingBackground/SecondViewController.m | 3 +- .../UINavigationController+Retro.h | 19 ++++++++++ .../UINavigationController+Retro.m | 35 +++++++++++++++++++ 5 files changed, 74 insertions(+), 3 deletions(-) create mode 100644 ChangingBackground/UINavigationController+Retro.h create mode 100644 ChangingBackground/UINavigationController+Retro.m diff --git a/ChangingBackground.xcodeproj/project.pbxproj b/ChangingBackground.xcodeproj/project.pbxproj index 633fb32..cc44438 100644 --- a/ChangingBackground.xcodeproj/project.pbxproj +++ b/ChangingBackground.xcodeproj/project.pbxproj @@ -24,6 +24,7 @@ 001809EC171C6764002D3E93 /* blue@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 001809E8171C6764002D3E93 /* blue@2x.png */; }; 001809ED171C6764002D3E93 /* green.png in Resources */ = {isa = PBXBuildFile; fileRef = 001809E9171C6764002D3E93 /* green.png */; }; 001809EE171C6764002D3E93 /* green@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 001809EA171C6764002D3E93 /* green@2x.png */; }; + 6458B71718230A4E0079E60D /* UINavigationController+Retro.m in Sources */ = {isa = PBXBuildFile; fileRef = 6458B71618230A4E0079E60D /* UINavigationController+Retro.m */; }; 647617291822C12B002D52E5 /* QuartzCore.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 647617281822C12B002D52E5 /* QuartzCore.framework */; }; /* End PBXBuildFile section */ @@ -51,6 +52,8 @@ 001809E8171C6764002D3E93 /* blue@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "blue@2x.png"; sourceTree = ""; }; 001809E9171C6764002D3E93 /* green.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = green.png; sourceTree = ""; }; 001809EA171C6764002D3E93 /* green@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "green@2x.png"; sourceTree = ""; }; + 6458B71518230A4E0079E60D /* UINavigationController+Retro.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "UINavigationController+Retro.h"; sourceTree = ""; }; + 6458B71618230A4E0079E60D /* UINavigationController+Retro.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "UINavigationController+Retro.m"; sourceTree = ""; }; 647617281822C12B002D52E5 /* QuartzCore.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = QuartzCore.framework; path = System/Library/Frameworks/QuartzCore.framework; sourceTree = SDKROOT; }; /* End PBXFileReference section */ @@ -73,6 +76,7 @@ isa = PBXGroup; children = ( 001809BE171C637E002D3E93 /* ChangingBackground */, + 6458B70F182305EA0079E60D /* vendor */, 001809B7171C637E002D3E93 /* Frameworks */, 001809B6171C637E002D3E93 /* Products */, ); @@ -171,6 +175,16 @@ name = BackgroundImages; sourceTree = ""; }; + 6458B70F182305EA0079E60D /* vendor */ = { + isa = PBXGroup; + children = ( + 6458B71518230A4E0079E60D /* UINavigationController+Retro.h */, + 6458B71618230A4E0079E60D /* UINavigationController+Retro.m */, + ); + name = vendor; + path = ChangingBackground; + sourceTree = ""; + }; /* End PBXGroup section */ /* Begin PBXNativeTarget section */ @@ -242,6 +256,7 @@ isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( + 6458B71718230A4E0079E60D /* UINavigationController+Retro.m in Sources */, 001809C5171C637E002D3E93 /* main.m in Sources */, 001809C9171C637E002D3E93 /* AppDelegate.m in Sources */, 001809D9171C6448002D3E93 /* FirstViewController.m in Sources */, diff --git a/ChangingBackground/FirstViewController.m b/ChangingBackground/FirstViewController.m index 91ff42d..a0e7c20 100644 --- a/ChangingBackground/FirstViewController.m +++ b/ChangingBackground/FirstViewController.m @@ -10,6 +10,7 @@ #import "FirstViewController.h" #import "SecondViewController.h" +#import "UINavigationController+Retro.h" @interface FirstViewController () @@ -19,7 +20,7 @@ @implementation FirstViewController - (IBAction)goForwardButtonPressed { SecondViewController *secondViewController = SecondViewController.new; - [self.navigationController pushViewController:secondViewController animated:YES]; + [self.navigationController pushViewControllerRetro:secondViewController]; } - (void) viewDidLoad { @@ -35,7 +36,7 @@ - (void) viewDidAppear:(BOOL)animated { UIImageView* blueBackground = [[window subviews] objectAtIndex:0]; UIImageView* greenBackground = [[window subviews] objectAtIndex:1]; - if (blueBackground.alpha != 1.0) { + if (blueBackground.alpha != 0.8) { [UIView animateWithDuration:1.5 delay:0.3 options:UIViewAnimationOptionTransitionNone animations:^{ blueBackground.alpha = 0.8; greenBackground.alpha = 0.2; diff --git a/ChangingBackground/SecondViewController.m b/ChangingBackground/SecondViewController.m index acddb32..937dfd9 100644 --- a/ChangingBackground/SecondViewController.m +++ b/ChangingBackground/SecondViewController.m @@ -7,12 +7,13 @@ // #import "SecondViewController.h" +#import "UINavigationController+Retro.h" @implementation SecondViewController - (IBAction)goBackButtonPressed { - [self.navigationController popViewControllerAnimated:YES]; + [self.navigationController popViewControllerRetro]; } - (void) viewDidLoad { diff --git a/ChangingBackground/UINavigationController+Retro.h b/ChangingBackground/UINavigationController+Retro.h new file mode 100644 index 0000000..87d081e --- /dev/null +++ b/ChangingBackground/UINavigationController+Retro.h @@ -0,0 +1,19 @@ +// +// UINavigationController+Retro.h +// ChangingBackground +// +// Created by Weien Wang on 10/31/13. +// Copyright (c) 2013 Ora Interactive. All rights reserved. +// + +#import + +@interface UINavigationController (Retro) + +//added to get around annoying iOS 7-style navigation animation +//thanks to http://stackoverflow.com/a/18882232/2284713 + +- (void)pushViewControllerRetro:(UIViewController *)viewController; +- (void)popViewControllerRetro; + +@end diff --git a/ChangingBackground/UINavigationController+Retro.m b/ChangingBackground/UINavigationController+Retro.m new file mode 100644 index 0000000..279773d --- /dev/null +++ b/ChangingBackground/UINavigationController+Retro.m @@ -0,0 +1,35 @@ +// +// UINavigationController+Retro.m +// ChangingBackground +// +// Created by Weien Wang on 10/31/13. +// Copyright (c) 2013 Ora Interactive. All rights reserved. +// + +#import "UINavigationController+Retro.h" + +@implementation UINavigationController (Retro) + +- (void)pushViewControllerRetro:(UIViewController *)viewController { + CATransition *transition = [CATransition animation]; + transition.duration = 0.25; + transition.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut]; + transition.type = kCATransitionPush; + transition.subtype = kCATransitionFromRight; + [self.view.layer addAnimation:transition forKey:nil]; + + [self pushViewController:viewController animated:NO]; +} + +- (void)popViewControllerRetro { + CATransition *transition = [CATransition animation]; + transition.duration = 0.25; + transition.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut]; + transition.type = kCATransitionPush; + transition.subtype = kCATransitionFromLeft; + [self.view.layer addAnimation:transition forKey:nil]; + + [self popViewControllerAnimated:NO]; +} + +@end From de5bef8398aa6fc9f5dcacd8d084db12c0acb0a0 Mon Sep 17 00:00:00 2001 From: Weien Wang Date: Thu, 31 Oct 2013 17:06:31 -0500 Subject: [PATCH 13/14] [FIX] condition for green>blue animation --- ChangingBackground/FirstViewController.m | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ChangingBackground/FirstViewController.m b/ChangingBackground/FirstViewController.m index a0e7c20..266c634 100644 --- a/ChangingBackground/FirstViewController.m +++ b/ChangingBackground/FirstViewController.m @@ -36,7 +36,7 @@ - (void) viewDidAppear:(BOOL)animated { UIImageView* blueBackground = [[window subviews] objectAtIndex:0]; UIImageView* greenBackground = [[window subviews] objectAtIndex:1]; - if (blueBackground.alpha != 0.8) { + if (blueBackground.alpha < 0.8) { [UIView animateWithDuration:1.5 delay:0.3 options:UIViewAnimationOptionTransitionNone animations:^{ blueBackground.alpha = 0.8; greenBackground.alpha = 0.2; From db2f36775da3693d37e55939269ff40da23eafd7 Mon Sep 17 00:00:00 2001 From: Weien Wang Date: Thu, 31 Oct 2013 17:09:48 -0500 Subject: [PATCH 14/14] minor cleanup --- ChangingBackground/AppDelegate.m | 1 - ChangingBackground/FirstViewController.m | 1 + ChangingBackground/SecondViewController.m | 2 ++ 3 files changed, 3 insertions(+), 1 deletion(-) diff --git a/ChangingBackground/AppDelegate.m b/ChangingBackground/AppDelegate.m index 58adc7b..9f9b9f2 100644 --- a/ChangingBackground/AppDelegate.m +++ b/ChangingBackground/AppDelegate.m @@ -14,7 +14,6 @@ @interface AppDelegate () { } @end - @implementation AppDelegate - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { diff --git a/ChangingBackground/FirstViewController.m b/ChangingBackground/FirstViewController.m index 266c634..324d690 100644 --- a/ChangingBackground/FirstViewController.m +++ b/ChangingBackground/FirstViewController.m @@ -33,6 +33,7 @@ - (void) viewDidAppear:(BOOL)animated { UIWindow* window = [UIApplication sharedApplication].keyWindow; + //(WW) UIImageView window subviews added in AppDelegate UIImageView* blueBackground = [[window subviews] objectAtIndex:0]; UIImageView* greenBackground = [[window subviews] objectAtIndex:1]; diff --git a/ChangingBackground/SecondViewController.m b/ChangingBackground/SecondViewController.m index 937dfd9..61cedac 100644 --- a/ChangingBackground/SecondViewController.m +++ b/ChangingBackground/SecondViewController.m @@ -25,6 +25,8 @@ - (void) viewDidAppear:(BOOL)animated { [super viewDidAppear:animated]; UIWindow* window = [UIApplication sharedApplication].keyWindow; + + //(WW) UIImageView window subviews added in AppDelegate UIImageView* blueBackground = [[window subviews] objectAtIndex:0]; UIImageView* greenBackground = [[window subviews] objectAtIndex:1];