From b704b8dfdd753440b740142f504bce0b758e72bc Mon Sep 17 00:00:00 2001 From: Bogdan Geleta Date: Thu, 20 Mar 2014 23:47:58 +0200 Subject: [PATCH] First and last commit --- ChangingBackground.xcodeproj/project.pbxproj | 5 + ChangingBackground/AppDelegate.h | 2 + ChangingBackground/AppDelegate.m | 7 + .../ChangingBackground-Info.plist | 2 - .../ChangingBackground-Prefix.pch | 4 + ChangingBackground/FirstViewController.m | 34 ++- ChangingBackground/FirstViewController.xib | 258 +++------------- ChangingBackground/SecondViewController.m | 34 ++- ChangingBackground/SecondViewController.xib | 284 +++--------------- 9 files changed, 165 insertions(+), 465 deletions(-) diff --git a/ChangingBackground.xcodeproj/project.pbxproj b/ChangingBackground.xcodeproj/project.pbxproj index 2e16be1..adfca81 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 */; }; + 25EEADBE18DB8E1D00DEF61F /* QuartzCore.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 25EEADBD18DB8E1D00DEF61F /* 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 = ""; }; + 25EEADBD18DB8E1D00DEF61F /* 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 = ( + 25EEADBE18DB8E1D00DEF61F /* 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 = ( + 25EEADBD18DB8E1D00DEF61F /* QuartzCore.framework */, 001809B8171C637E002D3E93 /* UIKit.framework */, 001809BA171C637E002D3E93 /* Foundation.framework */, 001809BC171C637E002D3E93 /* CoreGraphics.framework */, @@ -356,6 +360,7 @@ 001809D4171C637E002D3E93 /* Release */, ); defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; }; /* End XCConfigurationList section */ }; diff --git a/ChangingBackground/AppDelegate.h b/ChangingBackground/AppDelegate.h index f96be1d..5d3d25e 100644 --- a/ChangingBackground/AppDelegate.h +++ b/ChangingBackground/AppDelegate.h @@ -10,4 +10,6 @@ @interface AppDelegate : UIResponder +@property (nonatomic, strong) UIImageView *backgroundImageView; + @end diff --git a/ChangingBackground/AppDelegate.m b/ChangingBackground/AppDelegate.m index 9538cc1..50f7847 100644 --- a/ChangingBackground/AppDelegate.m +++ b/ChangingBackground/AppDelegate.m @@ -21,6 +21,8 @@ - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:( window = [UIWindow.alloc initWithFrame:UIScreen.mainScreen.bounds]; [window makeKeyAndVisible]; + [self addBackground]; + FirstViewController *firstViewController = FirstViewController.new; UINavigationController *navigationController = [UINavigationController.alloc initWithRootViewController:firstViewController]; [navigationController setNavigationBarHidden:YES]; @@ -30,4 +32,9 @@ - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:( return YES; } +- (void)addBackground { + self.backgroundImageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"blue"]]; + [window addSubview:self.backgroundImageView]; +} + @end diff --git a/ChangingBackground/ChangingBackground-Info.plist b/ChangingBackground/ChangingBackground-Info.plist index bab2011..29756b5 100644 --- a/ChangingBackground/ChangingBackground-Info.plist +++ b/ChangingBackground/ChangingBackground-Info.plist @@ -31,8 +31,6 @@ UISupportedInterfaceOrientations UIInterfaceOrientationPortrait - UIInterfaceOrientationLandscapeLeft - UIInterfaceOrientationLandscapeRight diff --git a/ChangingBackground/ChangingBackground-Prefix.pch b/ChangingBackground/ChangingBackground-Prefix.pch index 4a89986..683dcd7 100644 --- a/ChangingBackground/ChangingBackground-Prefix.pch +++ b/ChangingBackground/ChangingBackground-Prefix.pch @@ -11,4 +11,8 @@ #ifdef __OBJC__ #import #import + +#define kPushAnimationDuration 0.5f +#define kColorChangingDuration 1.5f + #endif diff --git a/ChangingBackground/FirstViewController.m b/ChangingBackground/FirstViewController.m index 8aedb68..78f0261 100644 --- a/ChangingBackground/FirstViewController.m +++ b/ChangingBackground/FirstViewController.m @@ -8,6 +8,8 @@ #import "FirstViewController.h" #import "SecondViewController.h" +#import "AppDelegate.h" +#import @interface FirstViewController () @@ -15,9 +17,39 @@ @interface FirstViewController () @implementation FirstViewController +- (void)viewDidAppear:(BOOL)animated { + [super viewDidAppear:animated]; + + [self updateBackgroundColor]; +} + + +- (void)updateBackgroundColor { + AppDelegate *delegate = (AppDelegate *)[[UIApplication sharedApplication] delegate]; + + dispatch_block_t animationBlock = ^{ + delegate.backgroundImageView.image = [UIImage imageNamed:@"blue"]; + }; + + [UIView transitionWithView:delegate.backgroundImageView + duration:kColorChangingDuration + options:UIViewAnimationOptionTransitionCrossDissolve + animations:animationBlock + completion:nil]; +} + - (IBAction)goForwardButtonPressed { SecondViewController *secondViewController = SecondViewController.new; - [self.navigationController pushViewController:secondViewController animated:YES]; + + CATransition* transition = [CATransition animation]; + + transition.duration = kPushAnimationDuration; + 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]; } @end diff --git a/ChangingBackground/FirstViewController.xib b/ChangingBackground/FirstViewController.xib index 0dd58c2..cf23c7d 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 028f811..238fb80 100644 --- a/ChangingBackground/SecondViewController.m +++ b/ChangingBackground/SecondViewController.m @@ -7,12 +7,42 @@ // #import "SecondViewController.h" - +#import "AppDelegate.h" +#import @implementation SecondViewController +- (void)viewDidAppear:(BOOL)animated { + [super viewDidAppear:animated]; + + [self updateBackgroundColor]; +} + + +- (void)updateBackgroundColor { + AppDelegate *delegate = (AppDelegate *)[[UIApplication sharedApplication] delegate]; + + dispatch_block_t animationBlock = ^{ + delegate.backgroundImageView.image = [UIImage imageNamed:@"green"]; + }; + + [UIView transitionWithView:delegate.backgroundImageView + duration:kColorChangingDuration + options:UIViewAnimationOptionTransitionCrossDissolve + animations:animationBlock + completion:nil]; +} + - (IBAction)goBackButtonPressed { - [self.navigationController popViewControllerAnimated:YES]; + CATransition* transition = [CATransition animation]; + + transition.duration = kPushAnimationDuration; + transition.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut]; + transition.type = kCATransitionPush; + transition.subtype = kCATransitionFromLeft; + + [self.navigationController.view.layer addAnimation:transition forKey:nil]; + [self.navigationController popToRootViewControllerAnimated:NO]; } @end diff --git a/ChangingBackground/SecondViewController.xib b/ChangingBackground/SecondViewController.xib index d603949..f714c56 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 - - + + + + + + + + + + + + + + + + + + + + + + + + + +