Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions ChangingBackground.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand All @@ -50,6 +51,8 @@
001809E8171C6764002D3E93 /* blue@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "blue@2x.png"; sourceTree = "<group>"; };
001809E9171C6764002D3E93 /* green.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = green.png; sourceTree = "<group>"; };
001809EA171C6764002D3E93 /* green@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "green@2x.png"; sourceTree = "<group>"; };
C92290DF18DA4399001CA299 /* BackgroundNavigationViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BackgroundNavigationViewController.h; sourceTree = "<group>"; };
C92290E018DA4399001CA299 /* BackgroundNavigationViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = BackgroundNavigationViewController.m; sourceTree = "<group>"; };
/* End PBXFileReference section */

/* Begin PBXFrameworksBuildPhase section */
Expand Down Expand Up @@ -152,6 +155,8 @@
001809DD171C64E3002D3E93 /* SecondViewController.h */,
001809DE171C64E3002D3E93 /* SecondViewController.m */,
001809DF171C64E3002D3E93 /* SecondViewController.xib */,
C92290DF18DA4399001CA299 /* BackgroundNavigationViewController.h */,
C92290E018DA4399001CA299 /* BackgroundNavigationViewController.m */,
);
name = SecondViewController;
sourceTree = "<group>";
Expand Down Expand Up @@ -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 */,
Expand Down Expand Up @@ -356,6 +362,7 @@
001809D4171C637E002D3E93 /* Release */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
/* End XCConfigurationList section */
};
Expand Down
3 changes: 2 additions & 1 deletion ChangingBackground/AppDelegate.m
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

#import "AppDelegate.h"
#import "FirstViewController.h"
#import "BackgroundNavigationViewController.h"

@interface AppDelegate () {
UIWindow *window;
Expand All @@ -22,7 +23,7 @@ - (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];

window.rootViewController = navigationController;
Expand Down
13 changes: 13 additions & 0 deletions ChangingBackground/BackgroundNavigationViewController.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
//
// BackgroundNavigationViewController.h
// ChangingBackground
//
// Created by Matthew Voracek on 3/19/14.
// Copyright (c) 2014 Ora Interactive. All rights reserved.
//

#import <UIKit/UIKit.h>

@interface BackgroundNavigationViewController : UINavigationController <UINavigationControllerDelegate>

@end
68 changes: 68 additions & 0 deletions ChangingBackground/BackgroundNavigationViewController.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
//
// 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 *backgroundNameShowing;
//@property NSString *backgroundNameHiding;

@property UIImageView *backgroundImageBlue;
@property UIImageView *backgroundImageGreen;
@property BOOL isBlueShowing;

@end

@implementation BackgroundNavigationViewController

- (void)viewDidLoad
{
[super viewDidLoad];

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
{

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
Loading