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 */; };
2E6A393D18E22BC400005199 /* QuartzCore.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 2E6A393A18E21BFB00005199 /* QuartzCore.framework */; };
/* End PBXBuildFile section */

/* Begin PBXFileReference section */
Expand All @@ -50,13 +51,16 @@
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>"; };
2E6A393A18E21BFB00005199 /* QuartzCore.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = QuartzCore.framework; path = System/Library/Frameworks/QuartzCore.framework; sourceTree = SDKROOT; };
2E6A393C18E22A6E00005199 /* Constants.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = Constants.h; sourceTree = "<group>"; };
/* End PBXFileReference section */

/* Begin PBXFrameworksBuildPhase section */
001809B2171C637E002D3E93 /* Frameworks */ = {
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
2E6A393D18E22BC400005199 /* QuartzCore.framework in Frameworks */,
001809B9171C637E002D3E93 /* UIKit.framework in Frameworks */,
001809BB171C637E002D3E93 /* Foundation.framework in Frameworks */,
001809BD171C637E002D3E93 /* CoreGraphics.framework in Frameworks */,
Expand Down Expand Up @@ -86,6 +90,7 @@
001809B7171C637E002D3E93 /* Frameworks */ = {
isa = PBXGroup;
children = (
2E6A393A18E21BFB00005199 /* QuartzCore.framework */,
001809B8171C637E002D3E93 /* UIKit.framework */,
001809BA171C637E002D3E93 /* Foundation.framework */,
001809BC171C637E002D3E93 /* CoreGraphics.framework */,
Expand Down Expand Up @@ -114,6 +119,7 @@
001809CA171C637E002D3E93 /* Default.png */,
001809CC171C637E002D3E93 /* Default@2x.png */,
001809CE171C637E002D3E93 /* Default-568h@2x.png */,
2E6A393C18E22A6E00005199 /* Constants.h */,
);
name = "Supporting Files";
sourceTree = "<group>";
Expand Down Expand Up @@ -356,6 +362,7 @@
001809D4171C637E002D3E93 /* Release */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
/* End XCConfigurationList section */
};
Expand Down
16 changes: 16 additions & 0 deletions ChangingBackground/Constants.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
//
// Constants.h
// ChangingBackground
//
// Created by Esteban Brenes on 3/25/14.
// Copyright (c) 2014 Ora Interactive. All rights reserved.
//

#import <Foundation/Foundation.h>

#define BLUE_BACKGROUND @"blue.png"
#define GREEN_BACKGROUND @"green.png"

@interface Constantes : NSObject

@end
5 changes: 4 additions & 1 deletion ChangingBackground/FirstViewController.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,10 @@
#import <UIKit/UIKit.h>

@interface FirstViewController : UIViewController

{
bool firstTime;
}
@property (weak, nonatomic) IBOutlet UIImageView *imgViewBackground;
- (IBAction)goForwardButtonPressed;

@end
46 changes: 46 additions & 0 deletions ChangingBackground/FirstViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,59 @@

#import "FirstViewController.h"
#import "SecondViewController.h"
#import "Constants.h"

@interface FirstViewController ()

@end

@implementation FirstViewController

-(void)viewDidLoad
{
[super viewDidLoad];
firstTime = YES;
// self.view.backgroundColor = [[UIColor alloc] initWithPatternImage:[UIImage imageNamed:BLUE_BACKGROUND]];
}


//***************************************************************
// used a fixed image here because its only 2 views but if there are more
//views with different backgorunds then i would have needed to pass some kind of
//parameter to identify the initial background to do the fade from
//***************************************************************
-(void)viewWillAppear:(BOOL)animated
{
if (!firstTime) {
// self.view.backgroundColor = [[UIColor alloc] initWithPatternImage:[UIImage imageNamed:GREEN_BACKGROUND]];
[[self imgViewBackground] setImage:[UIImage imageNamed:GREEN_BACKGROUND]];
}

}
- (void)viewDidAppear:(BOOL)animated
{
if (firstTime) {
firstTime = !firstTime;
}
else
{
//***************************************************************
//Had to switch from background color to uiimageview because the
//provided images wouldnt fit the screen on IOS7 or landscape
//***************************************************************

/* self.view.backgroundColor = [[UIColor alloc] initWithPatternImage:[UIImage imageNamed:BLUE_BACKGROUND]];
CATransition *transiton = [[CATransition alloc] init];
transiton.duration = 2.0;
[self.view.layer addAnimation:transiton forKey:@"Animation"];*/

[[self imgViewBackground] setImage:[UIImage imageNamed:BLUE_BACKGROUND]];
CATransition *transiton = [[CATransition alloc] init];
transiton.duration = 2.0;
[self.imgViewBackground.layer addAnimation:transiton forKey:@"Animation"];
}
}

- (IBAction)goForwardButtonPressed {
SecondViewController *secondViewController = SecondViewController.new;
[self.navigationController pushViewController:secondViewController animated:YES];
Expand Down
Loading