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

/* Begin PBXFileReference section */
Expand All @@ -50,13 +51,15 @@
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>"; };
915CD0461830BA5D00342C1A /* QuartzCore.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = QuartzCore.framework; path = System/Library/Frameworks/QuartzCore.framework; sourceTree = SDKROOT; };
/* End PBXFileReference section */

/* Begin PBXFrameworksBuildPhase section */
001809B2171C637E002D3E93 /* Frameworks */ = {
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
915CD0471830BA5D00342C1A /* 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 +89,7 @@
001809B7171C637E002D3E93 /* Frameworks */ = {
isa = PBXGroup;
children = (
915CD0461830BA5D00342C1A /* QuartzCore.framework */,
001809B8171C637E002D3E93 /* UIKit.framework */,
001809BA171C637E002D3E93 /* Foundation.framework */,
001809BC171C637E002D3E93 /* CoreGraphics.framework */,
Expand Down Expand Up @@ -321,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;
};
Expand All @@ -332,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;
};
Expand All @@ -356,6 +362,7 @@
001809D4171C637E002D3E93 /* Release */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
/* End XCConfigurationList section */
};
Expand Down
1 change: 1 addition & 0 deletions ChangingBackground/AppDelegate.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,6 @@
#import <UIKit/UIKit.h>

@interface AppDelegate : UIResponder <UIApplicationDelegate>
@property (nonatomic, strong) UIImageView *background;

@end
10 changes: 9 additions & 1 deletion ChangingBackground/AppDelegate.m
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#import "AppDelegate.h"
#import "FirstViewController.h"


@interface AppDelegate () {
UIWindow *window;
}
Expand All @@ -18,13 +19,20 @@ @interface AppDelegate () {
@implementation AppDelegate

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {


window = [UIWindow.alloc initWithFrame:UIScreen.mainScreen.bounds];

[window makeKeyAndVisible];


_background = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"blue"]];

[window addSubview:_background];
FirstViewController *firstViewController = FirstViewController.new;
UINavigationController *navigationController = [UINavigationController.alloc initWithRootViewController:firstViewController];
[navigationController setNavigationBarHidden:YES];


window.rootViewController = navigationController;

return YES;
Expand Down
4 changes: 4 additions & 0 deletions ChangingBackground/FirstViewController.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,13 @@
//

#import <UIKit/UIKit.h>
#import "AppDelegate.h"

@interface FirstViewController : UIViewController

- (IBAction)goForwardButtonPressed;
@property(strong, nonatomic) AppDelegate *delegate;
@property (weak, nonatomic) IBOutlet UIButton *goForwardButton;
@property (weak, nonatomic) IBOutlet UILabel *homeViewControllerLabel;

@end
34 changes: 31 additions & 3 deletions ChangingBackground/FirstViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,44 @@

#import "FirstViewController.h"
#import "SecondViewController.h"
#import "AppDelegate.h"

@interface FirstViewController ()

@end

@implementation FirstViewController
AppDelegate *delegate;

- (void)viewDidLoad {
[super viewDidLoad];
[self setUp1stViewControllerElements];

}

- (IBAction)goForwardButtonPressed {

SecondViewController *secondViewController = SecondViewController.new;
[self.navigationController pushViewController:secondViewController animated:YES];
CATransition* transition = [CATransition animation];
transition.duration = 0.5;
transition.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
transition.type = kCATransitionPush;
transition.subtype = kCATransitionFromRight;
[self.navigationController.view.layer addAnimation:transition forKey:nil];
[self.navigationController pushViewController:secondViewController animated:NO];
}

- (void)setUp1stViewControllerElements {
_goForwardButton.layer.cornerRadius = 10.0f;
_goForwardButton.backgroundColor = [UIColor whiteColor];
self.view.backgroundColor = [UIColor clearColor];
}

- (void)viewDidAppear:(BOOL)animated {
delegate = (AppDelegate *)[[UIApplication sharedApplication] delegate];

[UIView transitionWithView:delegate.background duration:2.0f options:UIViewAnimationOptionTransitionCrossDissolve animations:^{

delegate.background.image = [UIImage imageNamed:@"blue"];
} completion:^(BOOL finished) {
}];
}
@end
Loading