From 15cb1f8e463219e98f09261134a74505a761c95d Mon Sep 17 00:00:00 2001 From: mjvoracek Date: Wed, 19 Mar 2014 15:49:55 -0500 Subject: [PATCH 1/3] first commit --- ChangingBackground/FirstViewController.h | 4 +++ ChangingBackground/FirstViewController.m | 44 +++++++++++++++++++++++ ChangingBackground/SecondViewController.h | 3 ++ ChangingBackground/SecondViewController.m | 39 +++++++++++++++++++- 4 files changed, 89 insertions(+), 1 deletion(-) diff --git a/ChangingBackground/FirstViewController.h b/ChangingBackground/FirstViewController.h index a2fae46..ab70502 100644 --- a/ChangingBackground/FirstViewController.h +++ b/ChangingBackground/FirstViewController.h @@ -10,6 +10,10 @@ @interface FirstViewController : UIViewController +@property NSString *backgroundName; +@property UIImageView *backgroundImageBlue; +@property UIImageView *backgroundImageGreen; + - (IBAction)goForwardButtonPressed; @end diff --git a/ChangingBackground/FirstViewController.m b/ChangingBackground/FirstViewController.m index 8aedb68..1868773 100644 --- a/ChangingBackground/FirstViewController.m +++ b/ChangingBackground/FirstViewController.m @@ -10,14 +10,58 @@ #import "SecondViewController.h" @interface FirstViewController () +//@property SecondViewController *secondViewController; + +//@property UIImageView *backgroundImageGreen; @end @implementation FirstViewController +-(void)viewDidLoad +{ + [super viewDidLoad]; +} + +-(void)viewWillAppear:(BOOL)animated +{ + [super viewWillAppear:animated]; + + [self backgroundFade]; +} + - (IBAction)goForwardButtonPressed { SecondViewController *secondViewController = SecondViewController.new; [self.navigationController pushViewController:secondViewController animated:YES]; + [self backgroundFade]; + //_backgroundImageGreen.alpha = 0.0; +} + +- (void)backgroundFade +{ + if ([_backgroundName isEqualToString:@"blue"]) + { + _backgroundName = @"green"; + } + else + { + _backgroundName = @"blue"; + } + + UIImageView *backgroundImageBlue = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"blue"]]; + UIImageView *backgroundImageGreen = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"green"]]; + [self.view addSubview:backgroundImageGreen]; + backgroundImageGreen.alpha = 0.0; + [self.view sendSubviewToBack:backgroundImageGreen]; + [self.view addSubview:backgroundImageBlue]; + [self.view sendSubviewToBack:backgroundImageBlue]; + + + [UIImageView animateWithDuration:5.0 animations:^{ + backgroundImageGreen.alpha = 1; + } completion:^(BOOL finished) { + //[self.view removeFromSuperview]; + }]; } @end diff --git a/ChangingBackground/SecondViewController.h b/ChangingBackground/SecondViewController.h index 9ded32e..38d5bcc 100644 --- a/ChangingBackground/SecondViewController.h +++ b/ChangingBackground/SecondViewController.h @@ -10,6 +10,9 @@ @interface SecondViewController : UIViewController +@property NSString *backgroundName; + - (IBAction)goBackButtonPressed; +- (void)backgroundFade; @end diff --git a/ChangingBackground/SecondViewController.m b/ChangingBackground/SecondViewController.m index 028f811..9a4d05e 100644 --- a/ChangingBackground/SecondViewController.m +++ b/ChangingBackground/SecondViewController.m @@ -11,8 +11,45 @@ @implementation SecondViewController -- (IBAction)goBackButtonPressed { +-(void)viewWillAppear:(BOOL)animated +{ + [super viewWillAppear:animated]; + + [self backgroundFade]; +} + +- (IBAction)goBackButtonPressed +{ [self.navigationController popViewControllerAnimated:YES]; } +-(void)backgroundFade +{ + if ([_backgroundName isEqualToString:@"green"]) + { + _backgroundName = @"blue"; + } + else + { + _backgroundName = @"green"; + } + + + UIImageView *backgroundImageBlue = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"blue"]]; + UIImageView *backgroundImageGreen = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"green"]]; + [self.view addSubview:backgroundImageBlue]; + backgroundImageBlue.alpha = 0.0; + [self.view sendSubviewToBack:backgroundImageBlue]; + [self.view addSubview:backgroundImageGreen]; + [self.view sendSubviewToBack:backgroundImageGreen]; + + + [UIImageView animateWithDuration:5.0 animations:^{ + backgroundImageBlue.alpha = 1; + } completion:^(BOOL finished) { + //[self.view removeFromSuperview]; + }]; +} + + @end From da5aeaf4494398473e04088b6f2effc664c57e7c Mon Sep 17 00:00:00 2001 From: mjvoracek Date: Thu, 20 Mar 2014 10:30:16 -0500 Subject: [PATCH 2/3] Nav first commit --- ChangingBackground.xcodeproj/project.pbxproj | 7 + ChangingBackground/AppDelegate.m | 4 +- .../BackgroundNavigationViewController.h | 13 + .../BackgroundNavigationViewController.m | 45 +++ ChangingBackground/FirstViewController.h | 2 +- ChangingBackground/FirstViewController.m | 18 +- ChangingBackground/FirstViewController.xib | 258 +++------------- ChangingBackground/SecondViewController.m | 2 +- ChangingBackground/SecondViewController.xib | 284 +++--------------- 9 files changed, 168 insertions(+), 465 deletions(-) create mode 100644 ChangingBackground/BackgroundNavigationViewController.h create mode 100644 ChangingBackground/BackgroundNavigationViewController.m diff --git a/ChangingBackground.xcodeproj/project.pbxproj b/ChangingBackground.xcodeproj/project.pbxproj index 2e16be1..29b9e89 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 */; }; + C92290E118DA4399001CA299 /* BackgroundNavigationViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = C92290E018DA4399001CA299 /* BackgroundNavigationViewController.m */; }; /* End PBXBuildFile section */ /* Begin PBXFileReference section */ @@ -50,6 +51,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 = ""; }; + C92290DF18DA4399001CA299 /* BackgroundNavigationViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BackgroundNavigationViewController.h; sourceTree = ""; }; + C92290E018DA4399001CA299 /* BackgroundNavigationViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = BackgroundNavigationViewController.m; sourceTree = ""; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -152,6 +155,8 @@ 001809DD171C64E3002D3E93 /* SecondViewController.h */, 001809DE171C64E3002D3E93 /* SecondViewController.m */, 001809DF171C64E3002D3E93 /* SecondViewController.xib */, + C92290DF18DA4399001CA299 /* BackgroundNavigationViewController.h */, + C92290E018DA4399001CA299 /* BackgroundNavigationViewController.m */, ); name = SecondViewController; sourceTree = ""; @@ -238,6 +243,7 @@ isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( + C92290E118DA4399001CA299 /* BackgroundNavigationViewController.m in Sources */, 001809C5171C637E002D3E93 /* main.m in Sources */, 001809C9171C637E002D3E93 /* AppDelegate.m in Sources */, 001809D9171C6448002D3E93 /* FirstViewController.m in Sources */, @@ -356,6 +362,7 @@ 001809D4171C637E002D3E93 /* Release */, ); defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; }; /* End XCConfigurationList section */ }; diff --git a/ChangingBackground/AppDelegate.m b/ChangingBackground/AppDelegate.m index 9538cc1..e1e210f 100644 --- a/ChangingBackground/AppDelegate.m +++ b/ChangingBackground/AppDelegate.m @@ -8,6 +8,7 @@ #import "AppDelegate.h" #import "FirstViewController.h" +#import "BackgroundNavigationViewController.h" @interface AppDelegate () { UIWindow *window; @@ -22,8 +23,9 @@ - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:( [window makeKeyAndVisible]; FirstViewController *firstViewController = FirstViewController.new; - UINavigationController *navigationController = [UINavigationController.alloc initWithRootViewController:firstViewController]; + BackgroundNavigationViewController *navigationController = [BackgroundNavigationViewController.alloc initWithRootViewController:firstViewController]; [navigationController setNavigationBarHidden:YES]; + //navigationController.view.backgroundColor = [UIColor redColor]; window.rootViewController = navigationController; diff --git a/ChangingBackground/BackgroundNavigationViewController.h b/ChangingBackground/BackgroundNavigationViewController.h new file mode 100644 index 0000000..6fb8baf --- /dev/null +++ b/ChangingBackground/BackgroundNavigationViewController.h @@ -0,0 +1,13 @@ +// +// BackgroundNavigationViewController.h +// ChangingBackground +// +// Created by Matthew Voracek on 3/19/14. +// Copyright (c) 2014 Ora Interactive. All rights reserved. +// + +#import + +@interface BackgroundNavigationViewController : UINavigationController + +@end diff --git a/ChangingBackground/BackgroundNavigationViewController.m b/ChangingBackground/BackgroundNavigationViewController.m new file mode 100644 index 0000000..be8336e --- /dev/null +++ b/ChangingBackground/BackgroundNavigationViewController.m @@ -0,0 +1,45 @@ +// +// BackgroundNavigationViewController.m +// ChangingBackground +// +// Created by Matthew Voracek on 3/19/14. +// Copyright (c) 2014 Ora Interactive. All rights reserved. +// + +#import "BackgroundNavigationViewController.h" + +@interface BackgroundNavigationViewController () + +@property NSString *backgroundName; + +@end + +@implementation BackgroundNavigationViewController + +- (void)viewDidLoad +{ + [super viewDidLoad]; + + _backgroundName = @"blue"; + /* + UIImageView *backgroundImageBlue = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"blue"]]; + [self.view addSubview:backgroundImageBlue]; + [self.view sendSubviewToBack:backgroundImageBlue]; + */ +} + +-(void)navigationController:(UINavigationController *)navigationController didShowViewController:(UIViewController *)viewController animated:(BOOL)animated +{ + UIImageView *backgroundImageGreen = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"green"]]; + [self.view addSubview:backgroundImageGreen]; + backgroundImageGreen.alpha = 0.0; + [self.view sendSubviewToBack:backgroundImageGreen]; + + [UIImageView animateWithDuration:5.0 animations:^{ + backgroundImageGreen.alpha = 1; + } completion:^(BOOL finished) { + //[self.view removeFromSuperview]; + }]; +} + +@end diff --git a/ChangingBackground/FirstViewController.h b/ChangingBackground/FirstViewController.h index ab70502..2b52939 100644 --- a/ChangingBackground/FirstViewController.h +++ b/ChangingBackground/FirstViewController.h @@ -8,7 +8,7 @@ #import -@interface FirstViewController : UIViewController +@interface FirstViewController : UIViewController @property NSString *backgroundName; @property UIImageView *backgroundImageBlue; diff --git a/ChangingBackground/FirstViewController.m b/ChangingBackground/FirstViewController.m index 1868773..96a584e 100644 --- a/ChangingBackground/FirstViewController.m +++ b/ChangingBackground/FirstViewController.m @@ -8,6 +8,7 @@ #import "FirstViewController.h" #import "SecondViewController.h" +#import "BackgroundNavigationViewController.h" @interface FirstViewController () //@property SecondViewController *secondViewController; @@ -27,16 +28,29 @@ -(void)viewWillAppear:(BOOL)animated { [super viewWillAppear:animated]; - [self backgroundFade]; + //[self backgroundFade]; } - (IBAction)goForwardButtonPressed { SecondViewController *secondViewController = SecondViewController.new; [self.navigationController pushViewController:secondViewController animated:YES]; - [self backgroundFade]; //_backgroundImageGreen.alpha = 0.0; } +-(void)navigationController:(BackgroundNavigationViewController *)navigationController didShowViewController:(UIViewController *)viewController animated:(BOOL)animated +{ + UIImageView *backgroundImageGreen = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"green"]]; + [self.view addSubview:backgroundImageGreen]; + backgroundImageGreen.alpha = 0.0; + [self.view sendSubviewToBack:backgroundImageGreen]; + + [UIImageView animateWithDuration:5.0 animations:^{ + backgroundImageGreen.alpha = 1; + } completion:^(BOOL finished) { + //[self.view removeFromSuperview]; + }]; +} + - (void)backgroundFade { if ([_backgroundName isEqualToString:@"blue"]) diff --git a/ChangingBackground/FirstViewController.xib b/ChangingBackground/FirstViewController.xib index 0dd58c2..56404ab 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 - - + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/ChangingBackground/SecondViewController.m b/ChangingBackground/SecondViewController.m index 9a4d05e..e56a1b7 100644 --- a/ChangingBackground/SecondViewController.m +++ b/ChangingBackground/SecondViewController.m @@ -15,7 +15,7 @@ -(void)viewWillAppear:(BOOL)animated { [super viewWillAppear:animated]; - [self backgroundFade]; + //[self backgroundFade]; } - (IBAction)goBackButtonPressed diff --git a/ChangingBackground/SecondViewController.xib b/ChangingBackground/SecondViewController.xib index d603949..61ae89c 100644 --- a/ChangingBackground/SecondViewController.xib +++ b/ChangingBackground/SecondViewController.xib @@ -1,243 +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 - {{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 - - + + + + + + + + + + + + + + + + + + + + + + + + + + From ba65e89d6e07f2790882e290d0c4de9db7c73261 Mon Sep 17 00:00:00 2001 From: mjvoracek Date: Thu, 20 Mar 2014 18:38:19 -0500 Subject: [PATCH 3/3] Nav completed --- ChangingBackground/AppDelegate.m | 1 - .../BackgroundNavigationViewController.m | 57 ++++++++++++------ ChangingBackground/FirstViewController.h | 6 +- ChangingBackground/FirstViewController.m | 58 ------------------- ChangingBackground/SecondViewController.h | 3 - ChangingBackground/SecondViewController.m | 35 ----------- 6 files changed, 41 insertions(+), 119 deletions(-) diff --git a/ChangingBackground/AppDelegate.m b/ChangingBackground/AppDelegate.m index e1e210f..2259d2e 100644 --- a/ChangingBackground/AppDelegate.m +++ b/ChangingBackground/AppDelegate.m @@ -25,7 +25,6 @@ - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:( FirstViewController *firstViewController = FirstViewController.new; BackgroundNavigationViewController *navigationController = [BackgroundNavigationViewController.alloc initWithRootViewController:firstViewController]; [navigationController setNavigationBarHidden:YES]; - //navigationController.view.backgroundColor = [UIColor redColor]; window.rootViewController = navigationController; diff --git a/ChangingBackground/BackgroundNavigationViewController.m b/ChangingBackground/BackgroundNavigationViewController.m index be8336e..7c46590 100644 --- a/ChangingBackground/BackgroundNavigationViewController.m +++ b/ChangingBackground/BackgroundNavigationViewController.m @@ -10,7 +10,12 @@ @interface BackgroundNavigationViewController () -@property NSString *backgroundName; +//@property NSString *backgroundNameShowing; +//@property NSString *backgroundNameHiding; + +@property UIImageView *backgroundImageBlue; +@property UIImageView *backgroundImageGreen; +@property BOOL isBlueShowing; @end @@ -20,26 +25,44 @@ - (void)viewDidLoad { [super viewDidLoad]; - _backgroundName = @"blue"; - /* - UIImageView *backgroundImageBlue = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"blue"]]; - [self.view addSubview:backgroundImageBlue]; - [self.view sendSubviewToBack:backgroundImageBlue]; - */ + self.delegate = self; + + _backgroundImageBlue = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"blue"]]; + [self.view addSubview:_backgroundImageBlue]; + + _backgroundImageGreen = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"green"]]; + [self.view addSubview:_backgroundImageGreen]; + _backgroundImageGreen.alpha = 0.0; + [self.view sendSubviewToBack:_backgroundImageGreen]; + [self.view sendSubviewToBack:_backgroundImageBlue]; + _isBlueShowing = NO; } -(void)navigationController:(UINavigationController *)navigationController didShowViewController:(UIViewController *)viewController animated:(BOOL)animated { - UIImageView *backgroundImageGreen = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"green"]]; - [self.view addSubview:backgroundImageGreen]; - backgroundImageGreen.alpha = 0.0; - [self.view sendSubviewToBack:backgroundImageGreen]; - - [UIImageView animateWithDuration:5.0 animations:^{ - backgroundImageGreen.alpha = 1; - } completion:^(BOOL finished) { - //[self.view removeFromSuperview]; - }]; + + if (_isBlueShowing == YES) + { + [UIImageView animateWithDuration:5.0 animations:^{ + _backgroundImageGreen.alpha = 1; + } completion:^(BOOL finished) + { + _backgroundImageBlue.alpha = 0.0; + [self.view sendSubviewToBack:_backgroundImageGreen]; + _isBlueShowing = NO; + }]; + } + else + { + [UIImageView animateWithDuration:5.0 animations:^{ + _backgroundImageBlue.alpha = 1; + } completion:^(BOOL finished) + { + _backgroundImageGreen.alpha = 0.0; + [self.view sendSubviewToBack:_backgroundImageBlue]; + _isBlueShowing = YES; + }]; + } } @end diff --git a/ChangingBackground/FirstViewController.h b/ChangingBackground/FirstViewController.h index 2b52939..a2fae46 100644 --- a/ChangingBackground/FirstViewController.h +++ b/ChangingBackground/FirstViewController.h @@ -8,11 +8,7 @@ #import -@interface FirstViewController : UIViewController - -@property NSString *backgroundName; -@property UIImageView *backgroundImageBlue; -@property UIImageView *backgroundImageGreen; +@interface FirstViewController : UIViewController - (IBAction)goForwardButtonPressed; diff --git a/ChangingBackground/FirstViewController.m b/ChangingBackground/FirstViewController.m index 96a584e..8aedb68 100644 --- a/ChangingBackground/FirstViewController.m +++ b/ChangingBackground/FirstViewController.m @@ -8,74 +8,16 @@ #import "FirstViewController.h" #import "SecondViewController.h" -#import "BackgroundNavigationViewController.h" @interface FirstViewController () -//@property SecondViewController *secondViewController; - -//@property UIImageView *backgroundImageGreen; @end @implementation FirstViewController --(void)viewDidLoad -{ - [super viewDidLoad]; -} - --(void)viewWillAppear:(BOOL)animated -{ - [super viewWillAppear:animated]; - - //[self backgroundFade]; -} - - (IBAction)goForwardButtonPressed { SecondViewController *secondViewController = SecondViewController.new; [self.navigationController pushViewController:secondViewController animated:YES]; - //_backgroundImageGreen.alpha = 0.0; -} - --(void)navigationController:(BackgroundNavigationViewController *)navigationController didShowViewController:(UIViewController *)viewController animated:(BOOL)animated -{ - UIImageView *backgroundImageGreen = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"green"]]; - [self.view addSubview:backgroundImageGreen]; - backgroundImageGreen.alpha = 0.0; - [self.view sendSubviewToBack:backgroundImageGreen]; - - [UIImageView animateWithDuration:5.0 animations:^{ - backgroundImageGreen.alpha = 1; - } completion:^(BOOL finished) { - //[self.view removeFromSuperview]; - }]; -} - -- (void)backgroundFade -{ - if ([_backgroundName isEqualToString:@"blue"]) - { - _backgroundName = @"green"; - } - else - { - _backgroundName = @"blue"; - } - - UIImageView *backgroundImageBlue = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"blue"]]; - UIImageView *backgroundImageGreen = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"green"]]; - [self.view addSubview:backgroundImageGreen]; - backgroundImageGreen.alpha = 0.0; - [self.view sendSubviewToBack:backgroundImageGreen]; - [self.view addSubview:backgroundImageBlue]; - [self.view sendSubviewToBack:backgroundImageBlue]; - - - [UIImageView animateWithDuration:5.0 animations:^{ - backgroundImageGreen.alpha = 1; - } completion:^(BOOL finished) { - //[self.view removeFromSuperview]; - }]; } @end diff --git a/ChangingBackground/SecondViewController.h b/ChangingBackground/SecondViewController.h index 38d5bcc..9ded32e 100644 --- a/ChangingBackground/SecondViewController.h +++ b/ChangingBackground/SecondViewController.h @@ -10,9 +10,6 @@ @interface SecondViewController : UIViewController -@property NSString *backgroundName; - - (IBAction)goBackButtonPressed; -- (void)backgroundFade; @end diff --git a/ChangingBackground/SecondViewController.m b/ChangingBackground/SecondViewController.m index e56a1b7..7b36ed1 100644 --- a/ChangingBackground/SecondViewController.m +++ b/ChangingBackground/SecondViewController.m @@ -11,45 +11,10 @@ @implementation SecondViewController --(void)viewWillAppear:(BOOL)animated -{ - [super viewWillAppear:animated]; - - //[self backgroundFade]; -} - - (IBAction)goBackButtonPressed { [self.navigationController popViewControllerAnimated:YES]; } --(void)backgroundFade -{ - if ([_backgroundName isEqualToString:@"green"]) - { - _backgroundName = @"blue"; - } - else - { - _backgroundName = @"green"; - } - - - UIImageView *backgroundImageBlue = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"blue"]]; - UIImageView *backgroundImageGreen = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"green"]]; - [self.view addSubview:backgroundImageBlue]; - backgroundImageBlue.alpha = 0.0; - [self.view sendSubviewToBack:backgroundImageBlue]; - [self.view addSubview:backgroundImageGreen]; - [self.view sendSubviewToBack:backgroundImageGreen]; - - - [UIImageView animateWithDuration:5.0 animations:^{ - backgroundImageBlue.alpha = 1; - } completion:^(BOOL finished) { - //[self.view removeFromSuperview]; - }]; -} - @end